1

我正在尝试让 ShareActionProvider 工作,但遇到了以下问题:

此代码有效:

      Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Text I want to share");

    MenuItem shareItem = menu.findItem(R.id.share);
    mShareActionProvider = (ShareActionProvider) shareItem.getActionProvider();
    mShareActionProvider.setShareIntent(shareIntent);

但这不会:

      Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, webView.getUrl());

    MenuItem shareItem = menu.findItem(R.id.share);
    mShareActionProvider = (ShareActionProvider) shareItem.getActionProvider();
    mShareActionProvider.setShareIntent(shareIntent);

这是为什么?

4

1 回答 1

0

我不确定,但试试

shareIntent.putExtra(Intent.EXTRA_TEXT, webView.getUrl().toString());

代替

shareIntent.putExtra(Intent.EXTRA_TEXT, webView.getUrl());
于 2016-08-05T22:47:05.127 回答