I want the user to be able to share a link (to text content online). When shared, I also want a link to the app in the Play Store to appear below said link.
Via email, the shared might look like the following
Email subject: [content subject]
Email body:
[link to content]
Download our app here:
[link to app in Play Store]
I tried something like this, but it doesn't display the links:
String playStoreUrl = "market://details?id=" + getActivity().getApplicationContext().getPackageName();
ArrayList<String> links = new ArrayList<String>();
links.add(data.getLink());
links.add(playStoreUrl);
Intent sharingIntent2 = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharingIntent2.putExtra(Intent.EXTRA_SUBJECT, content.getSubject());
sharingIntent2.putStringArrayListExtra(Intent.EXTRA_TEXT, links);
sharingIntent2.setType("text/plan");
startActivity(Intent.createChooser(sharingIntent2, "Share this content"));
Any help is much appreciated! There doesn't seem to much documentation on this.
You can do it like this:
String YOUR_TEXT_TO_SEND=data.getLink()+"\n"+"Download our app here: "+"[link to app in Play Store]";
intent.putExtra(Intent.EXTRA_TEXT, YOUR_TEXT_TO_SEND);
Related
I have a share button. I share a message with some text and URL. It working well with whatsapp, Twitter and Gmail. But, in facebook share I'm able to share website link only. After, searching on web I have found ShareDialog class for facebook share.My question is how detect (ex: onClick() for facebook icon) when user click facebook icon on android default share dialog. Is it correct way ? or any other alternates is there?
My code :
public void shareApp() {
Intent sendIntent = new Intent();
String websiteLink = "https://www.manam.com";
String playStoreLink = "http://www.google.com";
String msg = "\nHey, found this cool & easy on-demand app.";
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, msg);
sendIntent.putExtra(Intent.EXTRA_TEXT,playStoreLink + msg);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, ""));
}
It's Facebook policy.
When you implement sharing, your app should not pre-fill any content to be shared. This is inconsistent with Facebook Platform Policy, see Facebook Platform Policy, 2.3.
I also don't see an option to detect click on facebook icon. And even if you can show your share dialog you wont be able to prefil any data
In my android app i want to share a Link to my website using intent but i dont want it to be visible to other user
example i want to share "smoe website link"
But to user it should look like "Click me to see it".
I tried this but wasnt successfull it just shows the simple text and was not clickable
<string name="app_link">Click me!</string>
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra("PostID", postID);
intent.putExtra("UserID", userID);
intent.putExtra(android.content.Intent.EXTRA_TEXT,activity.getString(R.string.app_link);
activity.startActivity(Intent.createChooser(intent, "Share"));
Any help will be really appreciated.
What you want is not realistically possible right now.
EXTRA_TEXT must always be interpreted as plain text by the receiving app. You could try using EXTRA_HTML_TEXT which was added with API 16. But many apps don't support HTML and will simply use EXTRA_TEXT instead (or not show any text at all if you omit EXTRA_TEXT).
Instagram for Android is very limited, from what I have seen so far. My scenario is simple: allow the user to edit a picture and when he clicks on Send:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
Then with queryIntentActivities() I search to see if Instagram is installed. If it is I send the path of my image to be uploaded:
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + path to myfile.png"));
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
share.putExtra(Intent.EXTRA_SUBJECT, "Sample subject");
share.putExtra(Intent.EXTRA_TEXT, "Sample text");
share.putExtra(Intent.EXTRA_TITLE, "Sample title");
The result: the image is uploaded using Instagram app (of course if I am logged in), but I can't add a Caption to it. None of the putExtra has any effect. So, is there any way to add a caption as intent parameter ?
And the other question, is it possible to open Instagram app with a certain user name filled in ?
It looks as if Instagram's Android App ignores EXTRA_TEXT, EXTRA_SUBJECT and EXTRA_TITLE, so it seems that adding a caption while uploading an image is not possible. By the way, you can try different approaches to check if it ignores those extras in every case:
OPTION #1: Changing the MIME type.
You are setting the MIME type to "image/jpeg". Try using "image/" or "/*" to check if their app doesn't ignore those extras.
share.setType("image/*");
or
share.setType("*/*");
OPTION #2:
As you are sending multiple MIME types (image and text), maybe their app is expecting ACTION_SEND_MULTIPLE instead of ACTION_SEND.
Intent share = new Intent(Intent.ACTION_SEND_MULTIPLE);
OPTION #3: Use MediaStore.Images.Media.insertImage(ContentResolver cr, String imagePath, String name, String description) function:
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), "file:///" + path to myfile.png", "Sample title", "Sample description")));
share.setType("image/jpeg");
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
OPTION #4: Post your issue in their developer forum, although there are similar questions that remain unsolved:
https://groups.google.com/forum/?fromgroups#!searchin/instagram-api-developers/caption$20action_send/instagram-api-developers/PJDuG2sTDlM/6bno5dZmoTEJ
https://groups.google.com/forum/?fromgroups#!searchin/instagram-api-developers/caption/instagram-api-developers/7XUKm9HSAdg/rJbdSnOmXacJ
And don't forget to come back and tell us their answer!
It looks like Instagram has updated their app to accept EXTRA_TEXT to add a caption. If the user has an updated version of Instagram (July 1, 2014 version or later) you can post an image and add a caption with the following code:
Intent instagram = new Intent(android.content.Intent.ACTION_SEND);
instagram.setType("image/*");
instagram.putExtra(Intent.EXTRA_STREAM, [URI of photo]);
instagram.putExtra(Intent.EXTRA_TEXT, [Text of caption]);
instagram.setPackage(instagramPackageName);
startActivity(instagram);
Users with older versions will still get the image, but not have the caption be pre populated.
This code is assuming you have already been through the auth flow.
Thanks in advance for your help.
I am developing an Android App that, as part of its core functionality, needs to send emails between users (peer-to-peer emails, not spam). These emails need to contain a link that will open the Android App upon a user-click
The problem I am having is: when I send these emails to gmail acounts, links appear as normal text rather than as links.
Here is my code
private void sendEmail(String recepientName, String recipientEmail) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { recipientEmail };
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Title");
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(
"<!DOCTYPE html><html><body>" +
"<br>Dear " + recepientName + ",<br>" +
"Please <font>click here</font></body></html>"));
startActivityForResult(emailIntent, EMAIL_REQUEST);
}
What should I do to make these link work in received emailsin gmail ?
Again Thanks
What I discovered was that somehow (probably with great talent) I got into Google's black list.
this means that Google stripped the link out of my code and the users saw it as regular text
HERE IS THE REASONING:
My link looked like this: myAppName://parameter1/parameter2/Parameter3
The prefix ("myAppName://") allows Android to identify my App and launch it as you click on the link.
HOWEVER:
When this link was sent to a gmail account, Google's servers were able to identify that this was an invalid link (pretty cool that they check that ha!!) and they stripped the link out.
The solution was to use a real URL for App identification and Launch:
Something like: http://myhost.com/parameter1/parameter2/Parameter3
Hope that helps
android:scheme="http" and the appropriate android:host
I have this code for sharing an app on facebook but when i share it it puts right links but wrong picture of the app
Button bShare = (Button) findViewById(R.id.button7);
bShare.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.myglobaljournal.christmascarol");
startActivity(Intent.createChooser(intent, "Share with"));
You can use the Debug tool to check how facebook "sees" this url.
From the result you can see that there are no og meta tags defined and so facebook probably takes a random picture from the content.
Edit
Facebook uses the open graph meta tags to extract info which is then used to render the share stories on the facebook experience.
You can see an example in the archived version of the Open Graph protocol, the new version uses the tags there but it's too complicated to your needs.
The only question is: can you any control over the output of the google play store for your app?
My guess is that you can't, and if you look at other examples (such as instagram or opera mobile) the image also appears random.