开发者

Trying to Send Email from Preference Screen

I have created preferences XML with Android Preference Activity like so:

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

Here is what I declared in my 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>

And here is my email 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);
    }



}

I get this error in 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=custome开发者_运维知识库rservice@tara.com }

Any help greatly appreciated!!!


You've declared your Activity in the manifest file as "EmailTara" but your activity class is called "EmailAccuwx". Also, your Activity's intent filter lists "com.sample.android.turboweather.EmailTara" but in your preferences xml, your creating an Intent for "android.intent.action.EMAIL_TARA".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜