开发者

Email activity on Android

开发者 https://www.devze.com 2023-03-05 10:37 出处:网络
I want to send email from Android virtual machine to my gmail account. Problem:but on pressing send button I am getting:

I want to send email from Android virtual machine to my gmail account. Problem: but on pressing send button I am getting:

"No applicat开发者_JAVA百科ion can perform this action"

Here is my code:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("audio/mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/download/test.mp3")); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(GlobalVariable.getstrEmail())); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(sendIntent, "Title:"));


Try it on a real device itself, it should work. And you need to change the type:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"email@example.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body text");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));


This can help...

  Intent openEmailIntent = new Intent(android.content.Intent.ACTION_SEND);
  openEmailIntent.setType("plain/text");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                           new String[{"zoombie@gmail.com"});
  openEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject you want");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Any body ");
  this.startActivity(Intent.createChooser(openEmailIntent,"Sharing via Email"));


try this....

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);        
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emailaddress});                                        
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));
0

精彩评论

暂无评论...
验证码 换一张
取 消