I would like to create a button in my app such that upon clicking facebook and twitter options would appear and user can immediately share my app.
Right now my codes are as below but it still doesn't work. Anyone knows the reason? I'm guessing I need to declare it on manifest but how do I go about?
public Intent onClick(View arg0) {
Intent normalIntent = new Intent(Intent.ACTION_SEND);
normalIntent.setType("text/plain");
normalIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
normalIntent.putExtra(Intent.EXTRA_TEXT, content);
return Intent.createChooser(normalIntent, "Share");
Related
I am navigating my app user to Gmail app when he clicks on a certain link inside my app. The redirection is working fine. But when the user hits the back button on the device or the toolbar of Gmail, he is redirected to Gmail inbox instead of getting the user back to my app.
I am doing something like so :-
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "some#email.address" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
Is there a way the user can be taken back to my app instead of Gmail inbox when clicked on back button, or some other solution to achieve this functionality? Any help is appreciated
Old question but you need to open the Gmail app in new task. add this flag to your intent.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
I am not sure if it is possible as you redirect the user to the another app which is another scope. Handling of the back button should be Gmail App's business then.
I also would like to know if there is any way to do it.
String mailto = "mailto:mailaddress1#domain.com" +
"?cc=" + "mailto:mailaddress2#domain.com" +
"&subject=" + Uri.encode("subject") +
"&body=" + Uri.encode("text is here");
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(mailto));
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e)
//TODO: Handle case where no email app is available
}
I have tried to send an e-mail using Gmail App. After sending an e-mail, I got back to my app but I have not found any way to implement an action for back button.
How can I launch an app (3rd party app) that is installed on my phone with my own app?
I'm having several buttons in my app and when one has pressed an app that is installed should open, for example, Bank of America app. (I want to create a customized menu).
I totally new to android programming, but could it work like this? What URI string could I use or how do I figure it out? Thanks a lot!
Button b_boa = (Button) findViewById(R.id.button_boa);
b_boa.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent open_boa = new Intent(Intent.ACTION_VIEW,
Uri.parse("_________"));
startActivity(open_boa);
}
});
You can launch a different app from your application on click of a button or something with the package name and if you dont know the launching activity of the application to be opened..You can use this
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
and if you know the launching activity also which you can see from the manifest file of the app to be open then use this.
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity"));
startActivity(intent);
I'm trying to set my Android application so that it's available to share links from other apps such as Chrome running on Android.
I have set an Intent Filter on an activity so that my app displays in the "Share via" dialog. That part works fine, but I'm not sure how to actually get the data into my "new post" dialog when it launches.
I read an existing StackOverflow question that suggests using this code:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, "I'm being sent!!");
startActivity(Intent.createChooser(share, "Share Text"));
I have an existing method for creating posts that looks like this:
public void onNewPostMenuSelected(MenuItem item) {
Intent intent = new Intent(this, CreatePostActivity.class);
startActivity(intent);
}
Should I modify this existing method and, if so, how? Or should I be doing something else? Thanks in advance!
I have set an Intent Filter on an activity so that my app displays in the "Share via" dialog. That part works fine, but I'm not sure how to actually get the data into my "new post" dialog when it launches.
If by "the data", you mean the text that was shared, call getIntent() on your activity and read the EXTRA_TEXT extra for that. In the case of browsers sharing URLs, EXTRA_TEXT should be the URL.
With the code below I share some text from my app via an intent chooser. My problem is that if I for example choose to share the text as a message and when in the message app I just hit the home button and bring my app back to front. Then when I try to start a new intent chooser it immediately sends me back to the unfinished message app. I would rather that it forgot all about that and presented me with the list of choices again.
Is there a way to make it forget the old choice?
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, "Share text as..."));
Add the following
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
Hi I have the following code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, message);
Now I can choose among a lot of applications: Gmail, Twitter, Facebook, SMS
But I don't want to display the Facebook option. Is this possible?
Or is it possible to add custom code when I click on the Facebook item? Like displaying an alertDialog etc
Try send the url like this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("http://www.google.com"));
intent.putExtra(Intent.EXTRA_TEXT, message);
You can
use the PackageManager to resolve the intent,
get the list of candidate applications,
exclude Facebook from that list
create the activity picker yourself with this updated list
This would be the exact opposite of Android Intent for Twitter application