I am stuck in my app trying to set a share button.
I have a simple textview to be shared with a few of social networks.
As i found out i cannot share just text with Facebook without using Facebook SDK.
Now i d like to know if is possibile to set a thing like. If user press whatsapp share my string if user press Facebook share the link of my app.
Below is my share button code.
case R.id.action_share:
Intent intent2=new Intent(Intent.ACTION_SEND);
intent2.setType("text/plain");
intent2.putExtra(Intent.EXTRA_TEXT, random + "\n"+"By Random Quotes" ); //random is the textview
startActivity(Intent.createChooser(intent2, "Share via"));
break;
you have to start activity with new task,like this:-
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
share.putExtra(Intent.EXTRA_SUBJECT, "share discription");
share.putExtra(Intent.EXTRA_TEXT,"text you want to share");
startActivity(Intent.createChooser(share,"you share title"));
}
Related
I'd like to share different information depending on the application selected by the user. For example, I'd like to send shorter text to Twitter than I do Gmail (otherwise, I go over in characters). Is there anyway to achieve this? Bonus question, is it possible to make hyperlinks via sharing via Gmail or SMS. For example, "Download here" where 'here' is a link instead of "Download by clicking the link below: http://..."
Current code:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, getTextToShare(data));
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, data.getTitle());
startActivity(Intent.createChooser(shareIntent, "Share this story"));
To find the selected share target this could be interesting for you: Branching the Android Share Intent extras depending on which method they choose to share
By using below code may helps you:
String shareText="Download <a href='[download link]'>here</a>";
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.toHtml(shareText));
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, data.getTitle());
startActivity(Intent.createChooser(shareIntent, "Share this story"));
Share Url Links and Texts into Social Networks (Facebook,Twitter and linkedin)
I am send an Intent with the action Intent.ACTION_SEND. This works fine and the user can pick what application to share with and so on.
The issue is when they pick Facebook Messenger to share. All I get is a white, modal screen with "Send to" in the top left and a search icon in the top right.
Here is the code that launches the intent.
Intent appIntent = new Intent(Intent.ACTION_SEND);
appIntent.setType("text/plain");
appIntent.putExtra(Intent.EXTRA_TEXT,"Check out this app. \nhttp://www.boxshark.co.uk");
appIntent.putExtra(Intent.EXTRA_SUBJECT,"Get the Boxshark app");
startActivity(Intent.createChooser(appIntent,"Share"));
I get that Facebook don't allow pre filled text when you use the share intent so my "Check out this app" text is removed. I don't understand however why the Facebook Messenger app is not doing anything however.
Any ideas anyone? Can you see anything wrong with my intent?
PackageManager pm=getPackageManager();
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/jpeg");
Uri uri = Uri.parse("android.resource://1/"+2);
i.putExtra(Intent.EXTRA_STREAM, uri);
PackageInfo info=pm.getPackageInfo("com.facebook.orca", PackageManager.GET_META_DATA);
i.setPackage("com.facebook.orca");
startActivity(Intent.createChooser(i, "Share with"));
1.your package name display in 1st line of your file
2.your image int value from srting which want to share
"com.facebook.orca" is facebook massanger package
Its work for me,hope your also
put only link, do not add text with link.
appIntent.putExtra(Intent.EXTRA_TEXT,"http://www.boxshark.co.uk")
I am working on android application. My app contains a listview and when each listitem is clicked I am displaying its
related content in new activity. Now I kept a share button in the new activity and when that button is clicked I am displaying an alert with
fb,twitter and email icon. Now when I click on twitter the text in that page should be posted in twitter. Similarly for facebook and email. Please suggest me
how to share text via social networking in android. I didnt work on sharing via social network android. Any suggestion or links may be helpful.
I have gone through examples in google but I didnt understood the flow.
use this and let user choose where he/she wants to share it
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Hello");
i.putExtra(Intent.EXTRA_TEXT, "I am sharing this");
try
{
this.startActivity(Intent.createChooser(i, "Share..."));
}
catch (android.content.ActivityNotFoundException ex)
{
//Error
return;
}
String message = "Text you want to share.";
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(shareIntent, your title here));
I need the share button to share the text in the textView in this way,I am a beginner in java and android
on Button Click
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,"Your score and Some extra text");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The title");
startActivity(Intent.createChooser(shareIntent, "Share..."));
create a method which will be called on share button and add this lines in it
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
Try this link as well.
Cheers
Take a look at how to use the Intent that launches the Share Via dialog.
See this post that has your answer :
Android Share Via Dialog
Here is a complete tutorial for this. http://mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/
I am beginner in android.I want to add FacebookShare button in my android application.I create the app in 2.2 .please help me
I use this code
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getResources().getString(R.string.title_activity_android_face_book_share));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,getResources().getString(R.string.title_activity_android_face_book_share));
startActivity(emailIntent);
I Use the following link also Best way for social sharing in Android
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, "URLyouWantToShare");
startActivity(Intent.createChooser(shareIntent, "Share..."));
Use the ACTION_SEND Intent, add the URL you want to share. User will be given a selection of apps to accept the share intent such as facebook etc.