1
我創建的喜好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] }
任何幫助非常感謝!
好的...我更新了我的代碼片段,現在我的電子郵件發送了,但我不得不更改我的電子郵件類以擴展「SettingsActivity」而不是「Activity」。另外,我只能選擇一次此首選項,但不會再次觸發電子郵件SettingsActivity的啓動。現在有什麼想法? – taraloca 2011-06-07 14:59:54