【问题标题】:android.content.ActivityNotFoundException: No Activity found to handle Intent to send emailsandroid.content.ActivityNotFoundException:没有找到处理意图发送电子邮件的活动
【发布时间】:2015-03-20 18:01:09
【问题描述】:

android 清单代码 电子邮件.java 电子邮件.xml 文件 是 下面

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shubham.myapplication" >

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action     
 android:name="com.example.shubham.myapplication.MAINACTIVITY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Menu"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.shubham.myapplication.MENU" 
   />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".TextPlay"
        android:label="@string/app_name" >

    </activity>
    <activity
        android:name=".TextPlay1"
        android:label="@string/app_name" >

    </activity>
    <activity
        android:name=".Email"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.content.Intent.ACTION_SEND" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

       </application>

      </manifest>

电子邮件.java

  package com.example.shubham.myapplication;

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

  public class Email extends Activity implements View.OnClickListener {

EditText personsEmail, intro, personsName, stupidThings, hatefulAction,
        outro;
String emailAdd, beginning, name, stupidAction, hatefulAct, out;
Button sendEmail;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.email);
    initializeVars();
    sendEmail.setOnClickListener(this);
}

private void initializeVars() {
    // TODO Auto-generated method stub
    personsEmail = (EditText) findViewById(R.id.etEmails);
    intro = (EditText) findViewById(R.id.etIntro);
    personsName = (EditText) findViewById(R.id.etName);
    stupidThings = (EditText) findViewById(R.id.etThings);
    hatefulAction = (EditText) findViewById(R.id.etAction);
    outro = (EditText) findViewById(R.id.etOutro);
    sendEmail = (Button) findViewById(R.id.bSentEmail);
}

public void onClick(View v) {
    // TODO Auto-generated method stub

    convertEditTextVarsIntoStringsAndYesThisIsAMethodWeCreated();
    String emailaddress[] = { emailAdd };
    String message = "Well hello "
            + name
            + " I just wanted to say "
            + beginning
            + ".  Not only that but I hate when you "
            + stupidAction
            + ", that just really makes me crazy.  I just want to make    
  you "
            + hatefulAct
            + ".  Welp, thats all I wanted to chit-chatter about, oh and"
            + out
            + ".  Oh also if you get bored you should check out your 
 stupidity"
            + '\n' + "PS. I think I love you...   :(";
    Intent ourIntent = new Intent(Intent.ACTION_SEND);
    ourIntent.putExtra(Intent.EXTRA_EMAIL,emailaddress);
    ourIntent.putExtra(Intent.EXTRA_SUBJECT,"I judgsjug you");
    ourIntent.putExtra(Intent.EXTRA_TEXT,message);
    startActivity(ourIntent);


}

private void convertEditTextVarsIntoStringsAndYesThisIsAMethodWeCreated() 
 {
    // TODO Auto-generated method stub
    emailAdd = personsEmail.getText().toString();
    beginning = intro.getText().toString();
    name = personsName.getText().toString();
    stupidAction = stupidThings.getText().toString();
    hatefulAct = hatefulAction.getText().toString();
    out = outro.getText().toString();
 }



 }

电子邮件.xml

  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout    
   xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:weightSum="100" android:layout_height="match_parent">
<ScrollView android:layout_weight="30" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout android:orientation="vertical"
        android:layout_width="match_parent"   
   android:layout_height="match_parent">
        <TextView android:text="Email address(es):"
            android:layout_width="wrap_content"     
   android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" 
 android:id="@+id/etEmails">
        </EditText>
        <TextView android:text="Hateful Intro:"
            android:layout_width="wrap_content" 
 android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" 
android:id="@+id/etIntro"></EditText>
        <TextView android:text="Person's name" 
android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" android:id="@+id/etName">        
    </EditText>
        <TextView android:text="Stupid Things that this Person does"
            android:layout_width="wrap_content" 
    android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent"
    android:id="@+id/etThings"></EditText>
        <TextView android:text="What you want to do to this person:"
            android:layout_width="wrap_content" 
     android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent"
      android:id="@+id/etAction"></EditText>
        <TextView android:text="Hateful Outro"
     android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content"
            android:layout_width="match_parent" 
   android:id="@+id/etOutro"></EditText>
    </LinearLayout>

 </ScrollView>
 <LinearLayout android:orientation="vertical"
    android:layout_width="match_parent" android:layout_weight="40"
    android:layout_height="fill_parent">
    <Button android:text="Send Email" android:id="@+id/bSentEmail"
        android:layout_width="fill_parent" 
 android:layout_height="fill_parent"></Button>
 </LinearLayout>
 <LinearLayout android:orientation="vertical"
    android:layout_width="match_parent" android:layout_weight="30"
    android:layout_height="fill_parent">
    <AnalogClock android:id="@+id/analogClock1"
        android:layout_width="fill_parent"
 android:layout_height="fill_parent"></AnalogClock>
 </LinearLayout>

  </LinearLayout>

这里发生了运行时异常 作为

987-1987/com.example.shubham.myapplication E/AndroidRuntime: FATAL EXCEPTION: main 进程:com.example.shubham.myapplication,PID:1987 android.content.ActivityNotFoundException: 没有找到处理 Intent { act=android.intent.action.SEND flg=0x1 (has clip) (has extras) }

【问题讨论】:

  • 任何帮助表示赞赏
  • 您希望哪个应用程序/活动接收此意图?您可以为此发布清单吗?

标签: android


【解决方案1】:

确保您在测试的移动设备上安装了任何电子邮件应用程序,并且

替换

 ourIntent.putExtra(Intent.EXTRA_TEXT,message);

ourIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(message);

同样的问题已经回答here.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-18
    • 2013-08-24
    相关资源
    最近更新 更多