hi friends i have a custom list coming from server and i want to add two share buttons for Gmail and Ymail resp. in that , its like when i click the Ymail share button it asks for username and password and then redirects me into the compose message section with message body as the link of the respective list and then i can access my contacts to send it to anyone i like.
1. please tell me how to do this??
2. is there any sdk available for Ymail/gmail
please suggest something..thanks in advance
to share text you don't pick the app you want to use. You pick the type of app you want to use. You can simply start an ACTION_SEND intent.
public void help() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
String s = getString(R.string.sharesubject);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, s);
startActivity(sendIntent);
}
(source: android.com)
How about a share action provider its brand new. my 1st app has a share action provider and it looks a little like this.
Basically you just fill up a share intent with the message and attach the intent to the share menu item.
search for share action provider example
Good Luck
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).
The problem is I have an article that want to share to other apps, and I want to let the user to choose which app to share to. What I want to share is basically:
the title of the article
the URL of the article
the article content as HTML
the URL with some extra text (such as 'http://foo.com/article share from #FooApp')
All of these fields are optional, but I want to share at least one of them.
Such as when share via SMS or twitter, I want to set the content to part 4. when share via Facebook, I want to set 1, 2, 3 together. And when share via email, I want to set subject as 1 and message as 4.
I know (correct me if I'm wrong) every target intent receiver has it's own logic to pick up the fields it needed. So I want to provide as much information as possible and I wrote the following code:
String message = article.getURL() + " #FooApp";
Intent intent = new Intent().setData(Uri.parse(article.getURL())
.putExtra(Intent.EXTRA_SUBJECT, article.getTitle())
.putExtra(Intent.EXTRA_TEXT, message)
.putExtra(Intent.EXTRA_HTML_TEXT, article.getHTML())
.putExtra("sms_body", message)
...
.setType(HTTP.PLAIN_TEXT_TYPE);
startActivity(Intent.createChooser(intent, "Share to"));
But the problem is, it seems like a trick between setData, putExtra, setType.
For some apps appear in the chooser dialog, when I choose, the confirm share window (of that app) display nothing that I set to the intent. (for some other apps they just say failed to fetch resource)
For the putExtra part, when I add or remove some putExtra code, the target intent receivers diff a lot than I expected.
So the question is: am I doing it the wrong way? Are there some guideline for this problem?
Trying to test the share function of the app, which is in the app it calls createChooser() to open the "sharing" chooser form.
startActivity(Intent.createChooser(sharingIntent, "Share something"));
Question is after the "sharing" chooser form is up how to simulate the clicking on some listed apps item, lets say there is app has description "AppName". Tried following it does not work, the chooser form stays there until the test timeout.
tried:
onView(withContentDescription("AppName"))
.perform(click());
and:
onView(withText("AppName"))
.perform(click());
Below is the example to share something in whatsapp:
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
waIntent.setPackage("com.whatsapp");//package name of whatsapp
waIntent.putExtra(Intent.EXTRA_TEXT, "Share Something");//text to share
startActivity(Intent.createChooser(waIntent,"Share via..."));
I hope this might help you.
On Android, I need to create my own IME which lets users to choose an image and send it right away to the already open WhatsApp, Email, Facebook, etc window,
without showing any extra chooser (cause we're already working with the contact we wnat to send the image to).
To have a better idea, it should work as an emoji keyboard but using my own images, similar to the Ikea emoticons app.
I've already tried with Intent, but couldn't find a way to point it to the already active contact window.
Here's the code:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setPackage("com.whatsapp");
sendIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
sendIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
sendIntent.setType("image/jpeg");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(sendIntent);