0

i am developing an application which is related to email sharing. and sharing using ACTION_SEND intent is great, but the problem is I don't want every sharing option there, I'd rather limit it to FB, Twitter. I want to display only email clients.

And i tried ACTION_SENDTO intent also instead of ACTION_SEND then getting "No apps can perform this action". how to resolve this? please anyone have idea please help me..

Thanks in advance..

user512
  • 403
  • 4
  • 21
  • 1
    You should check out this example: http://stackoverflow.com/questions/9730243/how-to-filter-specific-apps-for-action-send-intent-and-set-a-different-text-for – Sohil R. Memon Apr 30 '15 at 09:09
  • i seen above link and tried but getting which apps are supported intent.setType("message/rfc822") like hike,skype,messages etc.. – user512 Apr 30 '15 at 09:17

1 Answers1

0

Use intent.setPackage("com.google.android.gm") - Set your package (make sure to check if the package exists or not). to use gmail for sharing.

Above will send mail directly going with gmail. But there is another way is : Try

Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                "mailto", mailId, null));
        emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent, "Send Mail"));
Kirankumar Zinzuvadia
  • 1,249
  • 10
  • 17
  • thanks for reply... but i don't want redirect to any app directly.. i want to show all email options to user then user have a choice to select among those.. – user512 Apr 30 '15 at 09:26
  • i tried second one also in this case i'm getting dialog with message "No apps can perform this action" – user512 Apr 30 '15 at 09:28
  • I think sohil's link is correct example to that way. Just remove some unnecessary conditions from `for loop`. http://stackoverflow.com/questions/9730243/how-to-filter-specific-apps-for-action-send-intent-and-set-a-different-text-for – Kirankumar Zinzuvadia Apr 30 '15 at 09:42
  • i think its not helped to me because i need what email applications were installed in device but in that he is checking manually right.. we don't know all email applications right so how do we figure out it what the app user using? – user512 Apr 30 '15 at 09:51
  • `emailIntent.setType("message/rfc822");` This is used to set intent as mail intent. And make action to Intent.ACTION_SEND. – Kirankumar Zinzuvadia Apr 30 '15 at 09:54
  • using the above what you mentioned i'm getting 6 clients (Gmail,hike,skype,Gmail,Drive,messages). getting duplicates also like Gmail.. – user512 Apr 30 '15 at 10:03