问题
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