I am using intent to get the list of all apps i can post text to. However, linkedin is not appearing in that list. Do i need to do anything extra for linkedin?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "dcsd");
package= mContext.getPackageManager();
List<ResolveInfo> appTargets= package.queryIntentActivities(shareIntent, 0);
I am able to get all other apps like Facebook, Twitter except LinkedIn?
What could be the possible reason?
Code is
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String shareBody = "https://developers.facebook.com/docs/android/share";
intent.putExtra(Intent.EXTRA_TITLE,"Share From Test App");
intent.putExtra(Intent.EXTRA_TEXT,shareBody);
intent.putExtra(Intent.EXTRA_SUBJECT, "hello");
startActivity(Intent.createChooser(intent, "Share With"));
Add this to the intent:
intent.putExtra(Intent.EXTRA_SUBJECT, "dsvs");
Related
I have to share text with link.
'Share Text' is followed as.
"Please click this. snapchat://video?param1=text "
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
context.startActivity(Intent.createChooser(intent, "Share"));
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_TEXT, Html.html(text));
context.startActivity(Intent.createChooser(intent, "Share"));
All code showed link as general text. It is not acted on SMS or gmail app, etc.
How can I solve this?
You need to use android.content.Intent.
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_TEXT, text);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title goes here")
context.startActivity(Intent.createChooser(intent, "Share"));
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
//This line for the link:
intent.putExtra(Intent.EXTRA_TEXT, text);
//This one for text suggestion:
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title goes here")
context.startActivity(Intent.createChooser(intent, "Share"));
It will show as text only as it is not a valid link. Test the link once and try it.
As we use "content://sms/inbox" for sms inbox, do we have anything like this for email.I want to read email from after selecting email client.I tried the following the code
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setType("message/rfc822");
Uri data = Uri.parse("content://mail/inbox");
intent.setData(data);
startactivity(intent);
I dont want to send mail,just to read the mail,So i cant use mailto:
You should use this :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);
I am sending mail via my app with this code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"email#example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject here");
intent.putExtra(Intent.EXTRA_TEXT, "body text");
Uri uri = Uri.parse("file://" + file_name+".jpg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Send email..."));
This works just fine, but how can I do this without Intent.createChooser and do not let the user choose app for sharing and go directly to Gmail app, assuming each android phone have it.
You can used the following code to open whatever intent you want eg gmail, facebook, email etc..Simple in the type as used in code pass "gmail" if you want to open gmail, pass "face" if u want to open facebook
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/html");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(intent, 0);
if (!resInfo.isEmpty())
{
for (ResolveInfo info : resInfo)
{
if (info.activityInfo.packageName.toLowerCase().contains(type) || info.activityInfo.name.toLowerCase().contains(type))
{
intent.putExtra(android.content.Intent.EXTRA_TEXT, htmlBody);
intent.setPackage(info.activityInfo.packageName);
startActivity(Intent.createChooser(intent, getResources().getString(R.string.share_send_text)));
}
}
String value = text.getText().toString();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"test#test.test"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, value);
startActivity(Intent.createChooser(intent, "Send Email"));
this code runs, but it show a list of applications like notepad (and other notepad app), whatsapp (and several chat app).
I need a list of only email clients. I done a long search but the code is always same.
try the following code with content type:
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, ""));
Edit1: Check out this post for sending email directly without opening the email client.
How can implement an intent for sharing some text in a dialog like this ?
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath));
try
{
startActivity(Intent.createChooser(intent, "Sending File..."));
}
There u are:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, YOUR_TEXT_TO_SEND);
startActivity(Intent.createChooser(intent, "Share with"));
You can also use my library Android Intents. See demo app for details