-3

I want change this message "Your phone is shut down" that appear when shut down the device.enter image description here

Do you have any ideas?

My app download videos in the background, I must warn you not to switch off the device if the download is not yet finished, such as happens when you shut down Windows and is downloading updates.

Ortensia C.
  • 4,666
  • 11
  • 43
  • 70
  • 1
    Its a system triggered dialog so, we possibly cannot change it. Do you mind telling why this use-case arose? – Shaishav Oct 05 '16 at 13:15
  • I edit the question – Ortensia C. Oct 05 '16 at 13:20
  • 2
    Yes, its not a nice UX to change these dialogs (even if possible at all). For your use-case, you need to handle these manually. [This SO question](http://stackoverflow.com/questions/10448304/handling-phone-shutdown-event-in-android) should help you in that. – Shaishav Oct 05 '16 at 13:22

2 Answers2

1

Adriana take a look at Intent.ACTION_SHUTDOWN, i am not sure if you can handle like you want.

Additionally this post is related to this.

Community
  • 1
  • 1
betorcs
  • 2,771
  • 22
  • 28
0

In AndroidManifest.xml:

<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<uses-permission android:name="android.permission.DEVICE_POWER"
    tools:ignore="ProtectedPermissions" />

MainActivity.java I intercept the power off button and force close system dialog and create a View custom above it

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_POWER) {
        // Do something here...
        event.startTracking(); // Needed to track long presses

        Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        sendBroadcast(closeDialog);
        mViewCustom.setVisibility(View.VISIBLE);

        return true;
    }
    return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_POWER) {

        return true;
    }
    return super.onKeyLongPress(keyCode, event);
}
Ortensia C.
  • 4,666
  • 11
  • 43
  • 70