适用于系统应用程序的Android java.lang.SecurityException [英] Android java.lang.SecurityException for system app
问题描述
我将一个应用程序安装为系统应用程序.
I installed an app as a system app.
这是应用程序的manifest
文件:
<manifest android:versionCode="1" android:versionName="1.0" package="com.myapp">
<uses-sdk android:minSdkVersion="3"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:label="@id/0x7F030001" android:icon="@id/0x7F020000" android:debuggable="true">
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="com.myapp.MyReceiver"/>
</intent-filter>
</receiver>
</application>
</manifest>
现在在我的应用中,出现以下消息异常:
now in my app I get an exception with this message:
java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
但是您可以看到我的应用程序确实请求了权限,并安装在/system/app文件夹中
but as you can see my app does request the permission and is installed in /system/app folder
有人可以帮助我了解问题所在以及为什么得到exception
Can someone help me understand what's wrong and why I get the exception
谢谢
我认为问题与android 4.4版本(API 19)中已更改的某些东西有关,因为在较旧的android版本中它确实可以工作!
I think the problem is connected to something that has changed in android 4.4 version (API 19) because in older versions of android it does work!
推荐答案
您需要将应用程序从/system/app移至/system/priv-app
You need to move your application from /system/app to /system/priv-app
您的应用应该是有权访问android.permission.WRITE_SECURE_SETTINGS的应用
Your app should be privileged app to access android.permission.WRITE_SECURE_SETTINGS
这篇关于适用于系统应用程序的Android java.lang.SecurityException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!