android-activityadbandroid-thingsactivity-finish

Android Things: How to exit Android Settings screen?


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.


Solution

  • 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.