尝试发送电子邮件从偏好设置屏幕

问题描述:

我创建的喜好XML与Android偏好活动,像这样:尝试发送电子邮件从偏好设置屏幕

<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> 

以下是我在我的清单中声明:

<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[]{"[email protected]"}); 
     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 [email protected] } 

任何帮助非常感谢!

你宣布你Activity清单文件为"EmailTara",但您的活动类被称为"EmailAccuwx"。此外,您的Activity的意图筛选器列表"com.sample.android.turboweather.EmailTara",但在您的偏好xml中,您为"android.intent.action.EMAIL_TARA"创建Intent

+0

好的...我更新了我的代码片段,现在我的电子邮件发送了,但我不得不更改我的电子邮件类以扩展“SettingsActivity”而不是“Activity”。另外,我只能选择一次此首选项,但不会再次触发电子邮件SettingsActivity的启动。现在有什么想法? – taraloca 2011-06-07 14:59:54