Android 共享从首选项发送的应用程序电子邮件屏幕
我正在尝试在我的Android应用程序中创建一个功能,允许用户将Android market中我的应用程序的链接共享给他们想通过电子邮件发送给的任何人 在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
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);
}
}