how to show activity chooser menu when dialing in android? - android

I am trying to show activity chooser menu when dialing a number. Following code works for me when sending an email (from real phone,doesn't work in emulator):
/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to#email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
/* Send it off to the Activity-Chooser */
this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
But when I change the code as:
Intent call = new Intent(android.content.Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + phoneNo));
this.startActivity(Intent.createChooser(call, "Hello there..."));
No activity chooser menu is shown, just straight dial. I also want to list skype in that menu. Do you have any idea?

As someone else answered in one of your previous questions, you really do need to read up on Intents and Filters. I'll give you a quick explanation though. An Intent is a type of message that Android applications can register to handle. If Skype is not installed, then it won't be able to register for that Intent and so won't show up in that menu. If it is installed and still doesn't show up, that means it's not registered for that Intent. I don't know the Android Skype app, but judging from the picture you linked in the other question, it seems that it does register for that Intent and will show up when installed.

Related

Bring user back to app when Gmail back button is clicked

I am navigating my app user to Gmail app when he clicks on a certain link inside my app. The redirection is working fine. But when the user hits the back button on the device or the toolbar of Gmail, he is redirected to Gmail inbox instead of getting the user back to my app.
I am doing something like so :-
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, ""));
Is there a way the user can be taken back to my app instead of Gmail inbox when clicked on back button, or some other solution to achieve this functionality? Any help is appreciated
Old question but you need to open the Gmail app in new task. add this flag to your intent.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
I am not sure if it is possible as you redirect the user to the another app which is another scope. Handling of the back button should be Gmail App's business then.
I also would like to know if there is any way to do it.
String mailto = "mailto:mailaddress1#domain.com" +
"?cc=" + "mailto:mailaddress2#domain.com" +
"&subject=" + Uri.encode("subject") +
"&body=" + Uri.encode("text is here");
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(mailto));
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e)
//TODO: Handle case where no email app is available
}
I have tried to send an e-mail using Gmail App. After sending an e-mail, I got back to my app but I have not found any way to implement an action for back button.

Android Intents: Sending message through email or sms, using the built-in app picker

GOAL: When user taps the Send to... button, I want android to open a list of apps that can send messages (email, sms, etc.). The user picks one. That apps opens with text message already fed in.
Here is the code I use to try to achieve that:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, outputTextView.getText());
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
PROBLEM: When running it, a list of available apps is correctly displayed (Gmail, Hangouts, Messenger, Keep, Translate, etc.). If I pick GMail, it works fine. BUT: If I pick Hangout, Keep, Translate or any of the other suggested apps, my text is not displayed in those.
What am I missing?
Try this code
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Try this code for Sharing!");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I'm trying to share data....");
Intent chooserIntent = Intent.createChooser(shareIntent, "Share with");
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(chooserIntent);

Default mail client continues to be running in background after mail is sent

I am using ACTION_SEND to send mails from my application. It works fine but the problem is, since am using Intent.FLAG_ACTIVITY_NEW_TASK flag to send the mail,the eMail client continues to run in the background even after the mail is sent. Worst it still shows my email as draft (yet to be sent).
I use the below code to send mail from a non-activity
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, "Report issue: \""+mIssueTitle+"\"");
intent.putExtra(Intent.EXTRA_TEXT, mailBody);
String[] mailIds = new String[] {getReportingMailId()};
intent.putExtra(Intent.EXTRA_EMAIL, mailIds);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
App.getContext().startActivity( intent );
How can i trigger the mail client to send the mail from a non activity without the mail client from running in background forever
Ok finally figured out the solution.
The problem is, am using Application#Context to start the activity. When ever we use Application#Context a new Task is created ( that's why, adding the flag Intent.FLAG_ACTIVITY_NEW_TASK in the intent if we don't add this Flag then app crashes) .
To avoid creation of new task all we need to do is use the right context ie., use the activities context. ("Be careful and avoid memory leaks in case storing the activity context reference"). So the code is as below
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, "Report issue: \""+mIssueTitle+"\"");
intent.putExtra(Intent.EXTRA_TEXT, mailBody);
String[] mailIds = new String[] {getReportingMailId()};
intent.putExtra(Intent.EXTRA_EMAIL, mailIds);
enclosingActivityContext.startActivity( intent );

Android intent chooser does not display list if earlier intent is not finished

With the code below I share some text from my app via an intent chooser. My problem is that if I for example choose to share the text as a message and when in the message app I just hit the home button and bring my app back to front. Then when I try to start a new intent chooser it immediately sends me back to the unfinished message app. I would rather that it forgot all about that and presented me with the list of choices again.
Is there a way to make it forget the old choice?
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, "Share text as..."));
Add the following
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

Fires Intent with four option for sending email

I write a code that fires an Intent for sending an email.
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent, getResources().getString(R.string.share_title_text)));
However, when this Intent is fired, I see many items on the list like Bluetooth, Gmail app, Facebook app and so on.
How can I filter this list and only show these four items:
Gmail, EverNote, Twitter and Facebook.
you can't control the application list, in fact every application that register for Intent android.content.Intent.ACTION_SEND will be shown in this list

Categories

Resources