Example usage for android.content Intent ACTION_MASTER_CLEAR

List of usage examples for android.content Intent ACTION_MASTER_CLEAR

Introduction

In this page you can find the example usage for android.content Intent ACTION_MASTER_CLEAR.

Prototype

String ACTION_MASTER_CLEAR

To view the source code for android.content Intent ACTION_MASTER_CLEAR.

Click Source Link

Document

Deprecated - use ACTION_FACTORY_RESET instead.

Usage

From source file:com.android.managedprovisioning.DeviceOwnerProvisioningActivity.java

private void error(int dialogMessage, boolean resetRequired) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this).setTitle(R.string.provisioning_error_title)
            .setMessage(dialogMessage).setCancelable(false);
    if (resetRequired) {
        alertBuilder.setPositiveButton(R.string.device_owner_error_reset,
                new DialogInterface.OnClickListener() {
                    @Override/*w  ww.  j av  a2 s  .c o  m*/
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();

                        // Factory reset the device.
                        Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
                        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                        intent.putExtra(Intent.EXTRA_REASON, "DeviceOwnerProvisioningActivity.error()");
                        sendBroadcast(intent);
                        stopService(new Intent(DeviceOwnerProvisioningActivity.this,
                                DeviceOwnerProvisioningService.class));
                        setResult(RESULT_CANCELED);
                        finish();
                    }
                });
    } else {
        alertBuilder.setPositiveButton(R.string.device_owner_error_ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();

                // Close activity.
                stopService(
                        new Intent(DeviceOwnerProvisioningActivity.this, DeviceOwnerProvisioningService.class));
                setResult(RESULT_CANCELED);
                finish();
            }
        });
    }
    alertBuilder.show();
}