为什么`Intent.createChooser(shareIntentWithJpgFileName)`退出工作?

Dal*_*ale 2 android android-security android-intent-chooser

图像文件不再通过选择器传递

代码startActivity(intent.createChooser(shareIntentWithJpgFileName))在我的应用程序中运行良好多年,但我注意到大约一个月前它不再将图像文件传递给用户在选择器对话框中选择的应用程序.我怀疑Android操作系统安全改组(再次!),但不知道如何继续.

如果用户在选择器对话框中选择任意数量的选项,则应用程序将打开,但不会显示该.jpg部分是意图的一部分.如果用户选择Google云端硬盘,我会通过它的吐司得到一个错误的提示:

上传失败:请求中不包含任何数据

以前的代码:

String fileName = data.getStringExtra(EXTRA_FILENAME);                    
Log.v(TAG, "Starting Share intent.  fileName: " + fileName); //This shows fileName: /storage/emulated/0/dcim/DalesApp/IMG_20190103_142555_8445288886207383328.jpg              
Intent shareIntentWithJpgFileName = new Intent(Intent.ACTION_SEND);                
shareIntentWithJpgFileName.setType("image/jpeg");                
File filePassedIn = new File(fileName); 
Log.v(TAG, "exists: " + filePassedIn.exists() + " canRead: " + filePassedIn.canRead());   // Result is exists: true canRead: true.  Thanks Mark!           
shareIntentWithJpgFileName.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", filePassedIn));                
shareIntentWithJpgFileName.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);                
startActivity(Intent.createChooser(shareIntentWithJpgFileName, "Share Image"));                
Run Code Online (Sandbox Code Playgroud)

另外,我将此作为以下内容的一部分AndroidManifest.xml:

<provider    
    android:name="android.support.v4.content.FileProvider"    
    android:authorities="${applicationId}.provider"    
    android:exported="false"    
    android:grantUriPermissions="true">    
    <meta-data    
        android:name="android.support.FILE_PROVIDER_PATHS"    
        android:resource="@xml/provider_paths"/>    
</provider>    
Run Code Online (Sandbox Code Playgroud)

这也是在AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Run Code Online (Sandbox Code Playgroud)

题

为什么这停止了工作,我怎么能让它再次运作?

我很乐意维护/更新/修复/更正/删除这个问题,如果您因任何原因发现它不满意,请给我指导.

附录

我将过滤器Logcat从仅显示选定的应用程序更改为无过滤器,并且能够看到来自所有应用程序的日志记录.弹出大概有50条左右的线.很难说哪些项目适用于我开始的意图,但有些项目显然是出于我的意图(在选择器对话框中选择了Google云端硬盘).我选了一些有趣的日志条目:

I/ActivityManager: START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0xb080001 cmp=com.google.android.apps.docs/.shareitem.UploadMenuActivity (has extras)} from uid 10196
E/SchedPolicy: open of /dev/cpuctl/bg_non_interactive/tasks failed: No such file or directory
I/ActivityManager: Start proc 12705:com.google.android.apps.docs/u0a92 for activity com.google.android.apps.docs/.shareitem.UploadMenuActivity
E/AsyncTask #3-DataSourceHelper: Uploading single file but neither EXTRA_STREAM nor EXTRA_TEXT is specified.
E/main-UploadMenuActivity: No files requested to be uploaded: android.intent.action.SEND
I/LaunchCheckinHandler: Displayed com.google.android.apps.docs/.shareitem.UploadMenuActivity,cp,ca,570
Run Code Online (Sandbox Code Playgroud)

我的下一步是检查"EXTRA_STREAM",我还没有完成,但我可能会接近解决这个问题.

ian*_*ake 5

ACTION_SEND根据文档使用Intent.EXTRA_STREAM二进制内容,而不是.MediaStore.EXTRA_OUTPUT