Android 共享意图不';在某些设备上无法打开
我使用的是:Android 共享意图不';在某些设备上无法打开,android,android-intent,share,share-intent,android-intent-chooser,Android,Android Intent,Share,Share Intent,Android Intent Chooser,我使用的是: ShareCompat.IntentBuilder .from(getActivity()) .setText("text") .setType("text/plain") .startChooser(); 我还尝试了以下方法: Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.
ShareCompat.IntentBuilder
.from(getActivity())
.setText("text")
.setType("text/plain")
.startChooser();
我还尝试了以下方法:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
sendIntent.setType("text/plain");
context.startActivity(sendIntent);
在我所有的模拟器上,版本从5到7。在以上两种代码中,意图都会打开,我正试图成功地分享作品的文本
Nexus 5X、HTC One M8都能工作。然而,当我使用三星设备时,当我调用上述两个代码时,版本5和7不会打开任何内容
编辑
我关闭了三星安卓5版的电池优化功能,它还能工作吗?然后我再次禁用了它,但它仍在工作。请尝试此代码
Intent intent_share = new Intent();
intent_share.setAction(Intent.ACTION_SEND);
intent_share.setFlags(R.drawable.ic_share);
intent_share.putExtra(Intent.EXTRA_TEXT, "www.googleplay.com/acount");
intent_share.setType("text/plain");
startActivity(Intent.createChooser(intent_share, "Share it"));
请检查我的编辑。