Skip to main content

when i invoke gmail to send some advice the bluetooth come out, too



this is my code to invoke gmail.







private void sendMail() {

// Device model

String PhoneModel = android.os.Build.MODEL;

// Android version

String AndroidVersion = android.os.Build.VERSION.RELEASE;



final Intent emailIntent = new Intent(

android.content.Intent.ACTION_SEND);



emailIntent.setType("plain/text");



emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,

new String[] { "****@gmail.com"});



emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,

"'some feedbace...");



emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "—— phoneModel:"

+ PhoneModel + ";ROM:" + AndroidVersion);



startActivity(Intent.createChooser(emailIntent, "Sending mail..."));

}







when i click the menu to invoke the gmail to send feedback,the bluetooth come out too,with the gmail,and waiting for me to select one.but i just want to invoke the gmail app.what's wrong with my code .anybody help please!


Comments

  1. You can try this:

    emailIntent.setType("application/octet-stream");


    Or alternatively you can use PackageManager to build a more limited set of Intents, and show your own dialog for the user to select their email app.

    but actually you are swimming against the tide of Android with what you're doing. Android is designed to allow for a message to be "Sent" and to show all apps that accept that intent, so be careful you don't remove options the user may actually want.

    ReplyDelete
  2. You can try using android.content.Intent.ACTION_SENDTO instead of ACTION_SEND. If you have multiple email clients installed it will still prompt you to choose one though.

    Have a look at this question for more info.

    If you absolutely have to use Gmail and not have android prompt the user you can try what is suggested in this answer (Note: I haven't tried this):


    If you specifically want GMail, you have to be a bit cleverer. (Note
    that the correct MIME type is actually "text/plain", not "plain/text".
    Do to an implementation oddity, GMail seems to be the only activity
    which responds to the latter, but this isn't a behavior I would count
    on.)

    ReplyDelete
  3. private void sendMail() {
    String body = "\n 机型:" + android.os.Build.MODEL + ";ROM:"
    + android.os.Build.VERSION.RELEASE;
    Uri mailUri = Uri.parse("mailto:byirain@gmail.com");
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mailUri);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "'易学堂'问题反馈与建议");
    emailIntent.putExtra(Intent.EXTRA_TEXT, body);
    startActivity(emailIntent);
    }


    I finally finished it, though the uri, like before

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 1 Final Exam 2011 latest (hot hot hot)

  Hi! I have been posted content of ccna1 final exam (latest and only question.) I will post the answer and insert image on sunday. If you care, please subscribe your email an become a first person have full test content. Subcribe now  Some question  have not content because this question have images content. So that can you wait for me? SUNDAY 1. A user sees the command prompt: Router(config-if)# . What task can be performed at this mode? Reload the device. Perform basic tests. Configure individual interfaces. Configure individual terminal lines. 2. Refer to the exhibit. Host A attempts to establish a TCP/IP session with host C. During this attempt, a frame was captured with the source MAC address 0050.7320.D632 and the destination MAC address 0030.8517.44C4. The packet inside the captured frame has an IP source address 192.168.7.5, and the destination IP address is 192.168.219.24. At which point in the network was this packet captured? leaving host A leaving ATL leaving...