这是我做的,它的工作。
的preferences.xml
<PreferenceScreen
android:title="Share the App"
android:summary="Share the App with your Friends.">
<intent android:action="myapp.action.SHARE_APP" />
</PreferenceScreen>
然后,我已将此添加到AndroidManifest.xml中
<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>
然后,我创建了一个ShareApp.java这里添加的代码。
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);
}
}
它的工作!顺便说一下UrSettings类是从PreferenceActivity扩展而来的。
想必您在EXTRA_TEXT正文中包含应用的市场网址? – 2011-05-22 16:43:00
那是正确的! – Aakash 2011-05-22 18:32:42