无法使用Android Beam发送EXTRA_STREAM意向

时间:2018-08-13 20:31:34

标签: android android-studio android-intent android-file android-beam

因此,我正在创建一个基于使用Android Beam发送文件的应用程序,该应用程序之前可以与我的Sony Xperia z3一起使用。但是现在有了我的新Oneplus 6,它似乎并没有通过Android Beam发送任何类型的文件。这是我的代码:

File file = new File("/storage/emulated/0/tests/test1.txt");
                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
                shareIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appList.get(pos).loadLabel(packageManager));
                shareIntent.setType("file/*");
                MainActivity.mainActivity.startActivityForResult(shareIntent,1);

它可以很好地工作,例如将其保存到Google Drive。另外,使用Android光束发送纯文本也可以很好地工作,就像我使用EXTRA_TEXT而不是EXTRA_STREAM一样。那么,你们知道要使用Android Beam发送文件需要做什么吗?

0 个答案:

没有答案