Now I'm in the following situation: our server sends ready-for-use JWT hash for current user card, but there are seems to no way to open "save to android pay" url from android app button: there are only web applications integration tutorial: https://developers.google.com/save-to-android-pay/reference/s2w-reference
So, I have to some way render this html: <g:savetoandroidpay jwt="JWT" onsuccess="successHandler" onfailure="failureHandler" /> into button and handle javascript callbacks from Java.
Or, maybe, there are some another way?
Uri androidPayUri = Uri.parse("https://www.android.com/payapp/savetoandroidpay/" + jwt);
Intent intent = new Intent(Intent.ACTION_VIEW, androidPayUri);
...
Here you can find an example JWT to test:
https://developers.google.com/save-to-android-pay/reference/s2w-reference
I found the "email link" way to do this, it can be used for Android app too:
addToAndroidPay.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.android.com/payapp/savetoandroidpay/" + token));
startActivity(intent);
}
});
Related
i asked a question on how should i open the playstore page using an app link on my app. i got an answer to use "market://details?id=" + appPackageName to open the play store app but instead of opening the playstore page its re opening my app. whats the fix?
enter code here
protected void Updateclick(View view) {
String appPackageName="io.kodular.samithuaz.smartQ";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
}
Try this.You need to specify proper store URI for the different stores.
take reference link
protected void Updateclick(View view) {
final String appPackageName = getPackageName();
try {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
what i was using was an image click that why it didnt worked. when i used a button click it worked.
I'm developing a material design app.
I want to open my app's facebook page when user clicks on the 'like on facebook' text (layout) in my app.
I've managed to open the facebook app but I am unable to figure out how can I open my page directly!
Here's what I've done so far:
LinearLayout linearLayoutFacebookContainer = (LinearLayout) findViewById(R.id.facebook_container);
linearLayoutFacebookContainer.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
final Handler handler3 = new Handler();
handler3.postDelayed(new Runnable() {
#Override
public void run() {
Intent facebookIntent = getPackageManager().getLaunchIntentForPackage("com.facebook.katana");
if (facebookIntent != null) {
// We found the activity now start the activity
facebookIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
facebookIntent.setData(Uri.parse("https://www.facebook.com/HumaneHelper/"));
startActivity(facebookIntent);
} else {
// Bring user to the market or let them choose an app?
facebookIntent = new Intent(Intent.ACTION_VIEW);
facebookIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
facebookIntent.setData(Uri.parse("https://www.facebook.com/HumaneHelper/"));
startActivity(facebookIntent);
}
}
}, 200);
}
});
Please let me know.
I'm a beginner, please cooperate.
Thanks in advance.
fb://page/{id} is the way to go:
final String url = "fb://page/" + facebookID
Intent facebookAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
facebookAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(facebookAppIntent);
Are you sure you are using the ID number of your Facebook page and NOT the username?
What I mean is that if, for example, you want to open the Facebook page of Facebook itself (i.e. https://www.facebook.com/facebook) you have to use:
fb://page/20531316728
Since 20531316728 is the ID of the Facebook page (while facebook is the username).
If you don't know the ID of your Facebook page, you can retrieve it opening:
https://graph.facebook.com/{username}
Courtesy: Open Facebook page via Facebook app
In my Android app, I have a button that when clicked, launches the external application of my choice to play a video (I gather that this is called an "implicit intent"). Here is the relevant Java code from my onCreate method.
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener
(
new Button.OnClickListener()
{
public void onClick(View v)
{
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("https://youtu.be/jxoG_Y6dvU8"), "video/*");
startActivity(i);
}
}
);
I expected this to work, since I've followed tutorials and the Android developers documentation pretty closely, but when I test my app in the AVD, instead of prompting a menu of external applications where I can view my video, the app crashes.
What is causing my app to crash?
Change your onClick method to below code. You should give the option to choose the external player.
#Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("https://youtu.be/jxoG_Y6dvU8"), "video/*");
startActivity(Intent.createChooser(intent, "Complete action using"));
}
Change your code to add this check:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("https://youtu.be/jxoG_Y6dvU8"), "video/*");
// Check there is an activity that can handle this intent
if (i.resolveActivity(getPackageManager()) == null) {
// TODO No activity available. Do something else.
} else {
startActivity(i);
}
Hi I have got this edit text field, when I click on this button I want what ever is on the edit text box to be emailed to a specific email address. How do I go about doing that ?
findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "email#email.com", null));
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_TEXT, R.id.feedback_comment);
startActivity(Intent.createChooser(intent, "Choose an Email client :"));
}
});
as you can see my edit text id is "feedback_comment". And I am passing that in the message.
I would also like to know if there is any way I could send this email in the background so that user doesn't have to see all of this in the front end. You click on the submit button and it sends the email to the specified address without having to play around on sending an email. I had a look at JavaMail and don't know where to start off, please someone help me start off. Thank You
first in onCreate ..
EditText editText = findViewById(R.id. feedback_comment);
then..
findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, "abc#mail.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "SUBJECT");
intent.putExtra(Intent.EXTRA_TEXT, editText.getText().toString().trim());
startActivity(Intent.createChooser(intent, "Choose an Email client :"));
}
});
You can use javaMail which has been ported to Android.
See more at :
Sending Email in Android using JavaMail API without using the default/built-in app
http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_(no_Intents)_in_Android
Hope it can help you.
Currently I have a Button which will share an URL with a friend by using WhatsApp.
However, is there a way to return them back to my app after the message has been sent?
Here is my code so far.
whatsapp_item.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent whatsapp_intent = new Intent();
whatsapp_intent.setAction(Intent.ACTION_SEND);
whatsapp_intent.putExtra(Intent.EXTRA_TEXT, "Hey, i think you will like this. Check it out " + url);
whatsapp_intent.setType("text/plain");
whatsapp_intent.setPackage("com.whatsapp");
startActivity(whatsapp_intent);
}
});