2

我正在为带有 Android Lollipop 的 Sony Smartwatch 3 开发 Android Wear 应用程序,但似乎找不到实现工作亭模式的方法。
我到处都看过,但似乎没有任何效果。
还尝试了屏幕固定,但在手表上没有选项(手动)并且添加startLockStart()到我的 onCreate 似乎没有任何作用 - 我仍然可以退出应用程序。

任何帮助或确认这是不可能的,将不胜感激

4

2 回答 2

1

Make sure you run Android L MR1 (Android 5.1). In Sony devices running L MR0 (Android 5.0), the Google implementation of startLockTask had a bug which made it possible to exit the app.

Since this is vanilla Google code, it's very likely it's the same situation on other OEM devices.

Also make sure your app's lockTaskMode is not 1, or 3 if you are not using a device admin application.

Hope this helps.

/Marek (Sony Mobile employee)

于 2015-12-24T10:58:01.710 回答
1

我在 Medium 上写了一篇博客,以在 Android Wear 上实现 Kiosk 模式。它在 Wear OS 2.X 上完全运行,在 Wear OS 1.X 上运行 90%。请检查

脚步 :

1: REORDER_TASKS : 在应用的 onPause 中重新排序你的应用到顶部。

ActivityManager activityManager = (ActivityManager) getApplicationContext()
                .getSystemService(Context.ACTIVITY_SERVICE);

        activityManager.moveTaskToFront(getTaskId(), 0);

2:在清单中将类别设置为活动:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.HOME" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

3:覆盖按钮的功能

public boolean onKeyDown(int keyCode, KeyEvent event){
    if (event.getRepeatCount() == 0) {
        if (keyCode == KeyEvent.KEYCODE_STEM_1) {
            // Do stuff
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_STEM_2) {
            // Do stuff
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_STEM_3) {
            // Do stuff
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

4:通过应用主题禁用滑动功能

<style name="AppTheme" parent="@android:style/Theme.DeviceDefault">
    <item name="android:windowSwipeToDismiss">false</item>
</style>

5:启动时重新启动应用程序

笔记 :

此功能对用户不友好,除非您有充分的理由,否则 Android Play 商店不会批准这些功能

于 2018-06-07T06:15:08.073 回答