当我应用共享意图时,我的应用程序将在android中关闭
我的问题是,当我当时使用共享事件时,我的第一个活动就关闭了当我应用共享意图时,我的应用程序将在android中关闭,android,android-intent,share,Android,Android Intent,Share,我的问题是,当我当时使用共享事件时,我的第一个活动就关闭了 public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem sha
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
MenuItem shareItem = (MenuItem) menu.findItem(R.id.action_share);
ShareActionProvider mShare = (ShareActionProvider)shareItem.getActionProvider();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("text/plain");`enter code here`
String Scategory_id = global.getcategoryid();
}
<item
android:id="@+id/action_share"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:actionProviderClass="android.widget.ShareActionProvider"/>
public boolean oncreateoptions菜单(菜单菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.main,menu);
MenuItem shareItem=(MenuItem)menu.findItem(R.id.action\u share);
ShareActionProvider mShare=(ShareActionProvider)shareItem.getActionProvider();
意向共享意向=新意向(意向.行动\发送);
shareIntent.setAction(Intent.ACTION\u SEND);
setType(“text/plain”);`在此处输入代码`
字符串Scategory_id=global.getcategoryid();
}
以上代码适用于菜单。XML和我在使用SHARE INTENT时遇到了问题。我的主应用程序在使用SHARE按钮后立即关闭。它应该在我的第一个应用程序上重定向。您需要在mShare上调用SetShareContent
mShare.setShareIntent(shareIntent);