“No Activity found to handle Intent” while emailing data

前端 未结 5 1010
深忆病人
深忆病人 2020-12-30 23:07

I am trying to mail data using this code:

email = (Button) findViewById(R.id.enail);
    email.setOnClickListener(new View.OnClickListener() {

        publi         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 23:25

    Call the StartActivity method in the following way:

        Intent emailIntent = new Intent(
                            android.content.Intent.ACTION_SEND);
                    emailIntent.setAction(Intent.ACTION_SEND);
                    emailIntent.setType("message/rfc822");
                    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                            new String[] { "" });
                    emailIntent.putExtra(android.content.Intent.EXTRA_CC, "");
                    emailIntent.putExtra(android.content.Intent.EXTRA_BCC, "");
                    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                            "Playlist Details");
                    emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(Detail));
                    emailIntent.setType("text/html");
    
    // FOLLOWING STATEMENT CHECKS WHETHER THERE IS ANY APP THAT CAN HANDLE OUR EMAIL INTENT 
    startActivity(Intent.createChooser(emailIntent,
                            "Send Email Using: "));
    

    If System do not find any eamil application, A nice Dialog will be shown:

    enter image description here


    I know that i am answering an old question, but maybe it can help someone.

提交回复
热议问题