Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 共享从首选项发送的应用程序电子邮件屏幕_Android_Android Intent_Preference - Fatal编程技术网

Android 共享从首选项发送的应用程序电子邮件屏幕

Android 共享从首选项发送的应用程序电子邮件屏幕,android,android-intent,preference,Android,Android Intent,Preference,我正在尝试在我的Android应用程序中创建一个功能,允许用户将Android market中我的应用程序的链接共享给他们想通过电子邮件发送给的任何人 在preferences.xml中,我创建了如下内容 <PreferenceScreen android:title="Share the App" android:summary="Share the App with your friends."> <int

我正在尝试在我的Android应用程序中创建一个功能,允许用户将Android market中我的应用程序的链接共享给他们想通过电子邮件发送给的任何人

preferences.xml
中,我创建了如下内容

<PreferenceScreen
            android:title="Share the App" 
            android:summary="Share the App with your friends.">

        <intent android:action="" />

</PreferenceScreen>

我不确定在
首选项屏幕
中单击共享应用程序时,我应该在此处放置什么意图以及如何处理它。我想打开电子邮件,并在邮件中预先填充主题和主题中应用程序的Android Market链接


用户将输入电子邮件并将其发送给他们的朋友。

以下是我所做的工作,它起到了作用

preferences.xml

<PreferenceScreen
            android:title="Share the App" 
            android:summary="Share the App with your Friends.">

        <intent android:action="myapp.action.SHARE_APP" />

</PreferenceScreen>

成功了!!顺便说一句,ursetings类是从PreferenceActivity扩展而来的。

您可能希望在额外的文本正文中包含应用程序的市场url?
<activity android:name=".ShareApp"
      android:theme="@style/Theme.MyApp">
      <intent-filter>
        <action android:name="myapp.action.SHARE_APP" />
        <category android:name="android.intent.category.DEFAULT"/>                      
      </intent-filter>
</activity>
public class ShareApp extends UrSettings {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("text/plain"); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey there! Cheers!");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Try MyApp!"); 
        startActivity(emailIntent);  
        super.onCreate(savedInstanceState);
    }
}