小编Rin*_*avi的帖子

设备所有者在非根设备(Android L)上,没有NFC,使用adb shell,dpm set-device-owner

这里的最终目的是在"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.

android kiosk-mode android-5.0-lollipop

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

android-5.0-lollipop ×1

kiosk-mode ×1