权限拒绝:不允许在机器人发送广播不允许、机器人、权限

2023-09-12 22:04:54 作者:亦难。

我创建了一个简单的摄像头应用程序。它工作正常,在Android中的所有除了Android 4.4系统版本。当我从我的相机应用程序的图片,我得到了下面的错误。

  java.lang.SecurityException异常:权限被拒绝:不允许从PID = 26089,UID发送广播android.intent.action.MEDIA_MOUNTED = 10120
 

错误出现:

在以下位置:

  sendBroadcast(新意图(Intent.ACTION_MEDIA_MOUNTED,Uri.parse(文件://+ Environment.getExternalStorageDirectory())));
 

如何为奇巧解决这个问题?

让我知道!

谢谢!

解决方案   

如何为奇巧解决这个问题?

这code从来没有合适的。幸运的是,Android是(最终)采取措施,以prevent应用程序从欺骗更多的系统广播这样的。

如果你想告诉机器人索引你把外部存储上的文件,或者使用MediaScannerConnection或ACTION_MEDIA_SCANNER_SCAN_FILE.

I have created a simple camera app. It works fine in all the versions of Android except Android 4.4. I get the following error when I take a picture from my camera App.

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED from pid=26089, uid=10120

Error comes up:

In the following place:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));

How to fix this issue for KITKAT?

Let me know!

Thanks!

解决方案

How to fix this issue for KITKAT?

That code has never been appropriate. Fortunately, Android is (finally) taking steps to prevent apps from spoofing more system broadcasts like this.

If you want to tell Android to index a file you put on external storage, either use MediaScannerConnection or ACTION_MEDIA_SCANNER_SCAN_FILE.

 
精彩推荐