默认电子邮件应用程序不适用于Intent.ACTION_SEND。为什么??? “ActivityNotFound异常

时间:2014-04-15 20:48:33

标签: android email android-intent android-activity

所以我从newboston教程编写了这个程序,它应该发送一封电子邮件。然而,当我点击按钮时,它表示没有找到应用程序来执行此操作,但是我在Play商店找到了应用程序的副本,当我按下该应用程序上的按钮时,它让我在“email”和“gmail”之间进行选择“不幸的是,我无法看到该副本应用程序的源代码,但他们必须做一些我不做的事情。我在三星galaxy s3 mini上运行它,但我不知道如果我的应用程序无法正常工作,但另一个应用程序可能会出现问题。必须是代码。有人可以帮忙吗请具体说明为什么我的工作不起作用,你的工作。谢谢!!!

package com.example.music;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AnalogClock;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Email extends Activity implements OnClickListener {

EditText addressET, introET, nameET, stupidThingsET, toDoET, outroET;
TextView tv1, tv2, tv3, tv4, tv5, tv6;
Button button;
AnalogClock clock; 

String address, intro, name, stupidThings, toDo, outro;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_email);

    initialiseVars();
}

//********ON CLICK LISTENER
@Override
public void onClick(View arg0) {

    convertToString();

    String[] addresses = { address };

    String message = "Well hello there "  
            + name + " I just wanted to say " 
            + intro + " and i hate it when you " 
            + stupidThings + " and i just want to " 
            + toDo + " and by the way " 
            + outro + " You are thee best programmer in the word fuckn  
genius";

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);   
//Since class/app is not specified will give user a choice of application that can   
recieve   
ACTION_SEND BITCH.
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, addresses); //         
Second parameter has to be an array
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "I hate you");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);

    startActivity(Intent.createChooser(emailIntent,
            "Send Email Using: "));

}
//*********END ON CLICK LISTENER

//****CONVERT VARS TO STRING
public void convertToString(){

    address = addressET.getText().toString();
    intro = introET.getText().toString();
    name = nameET.getText().toString();
    stupidThings = stupidThingsET.getText().toString();
    toDo = toDoET.getText().toString();
    outro = outroET.getText().toString();

}
//*******END OF CONVERTING VARS TO STRING

//*******INITIALISING VARIABLES
public void initialiseVars(){

    addressET = (EditText) findViewById(R.id.editText1);
    introET = (EditText) findViewById(R.id.editText2);
    nameET = (EditText) findViewById(R.id.editText3);
    stupidThingsET = (EditText) findViewById(R.id.editText4);
    toDoET = (EditText) findViewById(R.id.editText5);
    outroET = (EditText) findViewById(R.id.editText6);
    button = (Button) findViewById(R.id.button1);

    button.setOnClickListener(this);


}
//******END INITIALISE VARIABLES
}

0 个答案:

没有答案