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
Related
GOAL: When user taps the Send to... button, I want android to open a list of apps that can send messages (email, sms, etc.). The user picks one. That apps opens with text message already fed in.
Here is the code I use to try to achieve that:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, outputTextView.getText());
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
PROBLEM: When running it, a list of available apps is correctly displayed (Gmail, Hangouts, Messenger, Keep, Translate, etc.). If I pick GMail, it works fine. BUT: If I pick Hangout, Keep, Translate or any of the other suggested apps, my text is not displayed in those.
What am I missing?
Try this code
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Try this code for Sharing!");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I'm trying to share data....");
Intent chooserIntent = Intent.createChooser(shareIntent, "Share with");
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(chooserIntent);
I am using the code below.
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(Uri.parse("smsto:" + phno));
sendIntent.putExtra("sms_body", msg);
sendIntent.putExtra("exit_on_sent", true);
startActivity(sendIntent);
What should I add more?
You are looking for Share via Intent, something like:
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
//the line below is optional
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// Add data to the intent, the receiving app will decide what to do with it.
intent.putExtra(Intent.EXTRA_SUBJECT, “Some Subject Line”);
intent.putExtra(Intent.EXTRA_TEXT, “Body of the message”);
Also, you can use createChooser():
startActivity(Intent.createChooser(intent, “How do you want to share?”));
Refer:
How to filter specific apps for ACTION_SEND intent (and set a different text for each app)
http://android-developers.blogspot.in/2012/02/share-with-intents.html
Check this too:
http://developer.android.com/training/sharing/send.html
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);
I write a code that fires an Intent for sending an email.
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent, getResources().getString(R.string.share_title_text)));
However, when this Intent is fired, I see many items on the list like Bluetooth, Gmail app, Facebook app and so on.
How can I filter this list and only show these four items:
Gmail, EverNote, Twitter and Facebook.
you can't control the application list, in fact every application that register for Intent android.content.Intent.ACTION_SEND will be shown in this list
when starting an activity with ACTION_SEND intent I get a menu with gmail, facebook, bluetooth... How can I get only email apps in this menu?
Thanks
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent .putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{email});
intent.setType("text/plain");
startActivity(intent);
have you tried action ACTION_SENDTO and setting your email as a data? http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO
You always also can use explicit call of needed activity.
Use
ACTION_SENDTO instead of ACTION_SEND