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

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.