【问题标题】:when i apply share intent myapplication get closed in android当我应用共享意图时,我的应用程序在 android 中关闭
【发布时间】:2014-01-22 03:46:50
【问题描述】:

我的问题是当我当时使用分享事件时,我的第一个活动被关闭了

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

以上代码适用于菜单。 XML 和我在使用共享意图时遇到问题我的主要应用程序在使用共享按钮后实际关闭它应该在我的第一个应用程序上重定向

【问题讨论】:

    标签: android android-intent share


    【解决方案1】:

    您需要在 mShare 上调用 setShareIntent。

    mShare.setShareIntent(shareIntent);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-23
      • 1970-01-01
      • 2021-09-12
      • 2011-02-07
      • 1970-01-01
      • 2015-11-14
      相关资源
      最近更新 更多