尝试从首选项屏幕发送电子邮件

时间:2011-06-07 13:47:32

标签: android android-preferences

我已经使用Android Preference Activity创建了首选项XML,如下所示:

<PreferenceCategory
      android:title="@string/about">

     <PreferenceScreen
            android:title="@string/customer_support"
            android:summary="@string/email_description">
            <intent android:action="com.sample.android.turboweather.EMAIL_TARA"
             />
    </PreferenceScreen>

</PreferenceCategory>

这是我在Manifest中声明的内容:

 <activity android:name=".EmailTara"
              android:launchMode="singleTop"
              android:screenOrientation="portrait"
              android:configChanges="keyboardHidden|orientation">
          <intent-filter>
            <action android:name="com.sample.android.turboweather.EMAIL_TARA" />
            <category android:name="android.intent.category.DEFAULT"/>

          </intent-filter>
    </activity>

这是我的电子邮件活动:

public class EmailAccuwx extends SettingsActivity{
    private static final int EMAIL_SUCCESS = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Tara Android Flagship Application");
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"customerservice@tara.com"});
        emailIntent.putExtra(Intent.EXTRA_TEXT, "");
        emailIntent.setType("message/rfc822");
        startActivity(Intent.createChooser(emailIntent, "Email Client Chooser");

        super.onCreate(savedInstanceState);
    }



}

我在logcat中收到此错误:

06-07 09:43:52.570: ERROR/AndroidRuntime(1517): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EMAIL_TARA dat=customerservice@tara.com }

任何帮助都非常感谢!!!

1 个答案:

答案 0 :(得分:0)

您已将清单文件中的Activity声明为"EmailTara",但您的活动类名为"EmailAccuwx"。此外,您的Activity的意图过滤器列出了"com.sample.android.turboweather.EmailTara",但在您的偏好设置xml中,您为Intent创建了"android.intent.action.EMAIL_TARA"