Rin*_*avi 8 android kiosk-mode android-5.0-lollipop
这里的最终目的是在"kiosk mod"中安装一个设备.
他们 说你不需要NFC也不需要生根来实现应用程序成为设备所有者.我还没有看到这个方法的完整示例,但让我们试试:
adb shell dpm set-device-owner <package>/.<ReceiverImplementation>
Run Code Online (Sandbox Code Playgroud)
应该这样做...所以我这样做,并得到:
java.lang.SecurityException:
Neither user 2000 nor current process has android.permission.BIND_DEVICE_ADMIN.
Run Code Online (Sandbox Code Playgroud)
因此,以下代码返回false.
((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE))
.isDeviceOwnerApp(getApplicationContext().getPackageName())
Run Code Online (Sandbox Code Playgroud)
这个STO问题提出了类似的问题,但未指明实际的失败.
清单文件和源代码的其余部分主要来自这个谷歌示例
<manifest
package="com.example.android.deviceowner"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver
android:name=".DeviceOwnerReceiver"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_owner_receiver"/>
<intent-filter>
<action android:name="android.app.action.ACTION_DEVICE_ADMIN_ENABLED"/>
</intent-filter>
</receiver>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我试图这样做的设备目前是LG G Pad.
您的清单文件似乎是正确的。您应该意识到,它可能来自执行此命令时系统的状态。在成功运行命令之前应检查许多点dpm:
最好的办法(这就是我在实验时所做的)是完全从工厂重新启动您的手机并避免大多数配置步骤(除了强制性步骤“配置 Wi-Fi”和“名称”),并且不要关联任何谷歌帐户。
配置完成后,您一定会处于干净的状态。然后,
pm install...)安装您的应用程序adb shell dpm set-device-owner ... 我在我的博客上写了一篇文章解释了大部分步骤,请看一下,它可能对您的情况有用。
| 归档时间: |
|
| 查看次数: |
10153 次 |
| 最近记录: |