Android Things: How to exit Android Settings screen?

浪尽此生 提交于 2020-01-04 01:38:51

问题


I succeed to show Android Date Settings by calling :

startActivityForResult(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS), 0);

but I don't know how to exit, there is no cancel/update button, no back button or navigation bar.

Would anyone know how to leave this screen?

I use Android Things 0.5.1-devpreview on RPi3 with this example code.


回答1:


In order to close Android's settings app you can either send a back button press event

adb shell input keyevent 4

or force close the settings app

adb shell am force-stop com.android.settings

Or send an input event programmatically

Runtime.getRuntime().exec("input keyevent 4");

Just keep in mind that your app goes to background when the Android settings app gets started "hiding" your app's UI. You'll need to figure out how to trigger the programmatic solution.




回答2:


In your code just start some activity and it will overtake the settings screen.

For example, if u open settings screen to enable Location, u set a broadcast listener to On Location status change. The moment user enables location, you'll receive broadcast and there u start your activity. The settings screen will automatically close.



来源:https://stackoverflow.com/questions/46138662/android-things-how-to-exit-android-settings-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!