I want to share some image and text via Facebook from android jelly bean. it work's in all devices except android jelly bean. Anybody please help me how to resolve this issue.
my code
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Content to share");
PackageManager pm = v.getContext().getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList) {
if ((app.activityInfo.name).contains("facebook")) {
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
System.out.println("package name"+name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
v.getContext().startActivity(shareIntent);
break;
in this code i want to intent some text. But EXTRA_TEXT is not working.How to pass string or image in this EXTRA_TEXT.
Try out the below code. I have used this code to share the Text & Image from one of my application and its working great for me.
I hope it will work for you also.
In this i have used the image stored at particular location in the device. You can change it according to your image location.
Please refer the FaceBook Page for more details
It looks like we can not pass a text to share in Facebook App.
Facebook Share Intent Details
You shouldn't only target Facebook directly.
Instead you should just use the Share Intent. Pass your data in the extras as specified in the SDK and then have the user select which they want to share with. Don't force them to use facebook as they are NOT the only social media. Theres also twitter, 4square, and many others that the user uses. Let those apps handle your intent, don't dictate such a strict limitation as that is NOT how the intent action
ACTION_SEND
was meant to work.As for your issue with the Extra, obviously
EXTRA_TEXT
intent will not work because its not used for images or any references like that.Read the documentation
http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND
It says:
Given this information, you need to also set the mimetype for your particular data in your intent's type.