【发布时间】:2014-11-21 15:44:47
【问题描述】:
我正在寻求有关通过应用修改 Android 系统设置的帮助。
我无法让自定义 Android 应用在 Kitkat 4.4.2 下正常运行。我不确定我沮丧的根源是什么,但我认为我在清单中缺少某种安全设置或技巧。
背景:我不是开发人员,但这个项目落到了我的手中。在部署我们的平板电脑之前,我们将我们的 MDM 和公司 apk 安装到平板电脑上,并运行一个简单的程序来配置一些系统设置。我们在平板电脑上执行 root 并在此过程中安装 SU 二进制文件。
我已将 ACCESS_SUPERUSER 添加到我的清单中,但 SuperSU 没有提示我请求此应用的 SU 访问权限。此外,如果我尝试运行该应用程序,我会收到一条“应用程序未安装”的 toast 消息。 (我用下面的APPLICATION替换了应用名称)
Java 代码
Settings.Global.putInt(MainActivity.this.getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, 1);
Settings.Global.putInt(MainActivity.this.getContentResolver(), Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 1);
Settings.Secure.putInt(MainActivity.this.getContentResolver(), Settings.Secure.LOCK_PATERN_ENABLED, 0);
Settings.Secure.putInt(MainActivity.this.getContentResolver(), Settings.Secure.LOCK_PATTERN_VISIBLE, 0);
Settings.System.putInt(MainActivity.this.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 300000);
Settings.Secure.putInt(MainActivity.this.getContentResolver(), Settings.Global.ADB_ENABLED, 0);
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.APPLICATION"
android:versionCode="1"
android:versionName="1.2" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:persistent="false"
android:permission="android.permission.WRITE_SECURE_SETTINGS"
android:exported="true" >
<activity
android:name="com.example.APPLICATION.MainActivity"
android:label="@string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Logcat 错误
11-20 17:17:51.749:E/Launcher(686):Launcher 没有 启动 Intent { act=android.intent.action.MAIN 的权限 猫=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.APPLICATION/.MainActivity }。确保创建一个 MAIN 相应活动的意图过滤器或使用导出的 此活动的属性。 tag=ApplicationInfo(title=SetSet id=-1 类型=0 容器=-1 屏幕=-1 cellX=-1 cellY=-1 spanX=1 spanY=1 dropPos=null) 意图=意图 { 行为=android.intent.action.MAIN 猫=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.setset/.MainActivity }
11-20 17:32:16.169: E/AndroidRuntime(4744): java.lang.RuntimeException:无法启动活动 组件信息{com.example.setset/com.example.APPLICATION.MainActivity}: java.lang.SecurityException:权限拒绝:写入安全 设置需要 android.permission.WRITE_SECURE_SETTINGS
【问题讨论】:
标签: java android android-intent android-manifest android-4.4-kitkat