FileDocCategorySizeDatePackage
ExternalMediaFormatActivity.javaAPI DocAndroid 5.1 API3670Thu Mar 12 22:22:10 GMT 2015com.android.internal.app

ExternalMediaFormatActivity

public class ExternalMediaFormatActivity extends AlertActivity implements DialogInterface.OnClickListener
This activity is shown to the user to confirm formatting of external media. It uses the alert dialog style. It will be launched from a notification, or from settings

Fields Summary
private static final int
POSITIVE_BUTTON
private android.content.BroadcastReceiver
mStorageReceiver
Used to detect when the media state changes, in case we need to call finish()
Constructors Summary
Methods Summary
public voidonClick(android.content.DialogInterface dialog, int which)
{@inheritDoc}


        if (which == POSITIVE_BUTTON) {
            Intent intent = new Intent(ExternalStorageFormatter.FORMAT_ONLY);
            intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
            startService(intent);
        }

        // No matter what, finish the activity
        finish();
    
protected voidonCreate(android.os.Bundle savedInstanceState)

    
    
        
        super.onCreate(savedInstanceState);

        Log.d("ExternalMediaFormatActivity", "onCreate!");
        // Set up the "dialog"
        final AlertController.AlertParams p = mAlertParams;
        p.mTitle = getString(com.android.internal.R.string.extmedia_format_title);
        p.mMessage = getString(com.android.internal.R.string.extmedia_format_message);
        p.mPositiveButtonText = getString(com.android.internal.R.string.extmedia_format_button_format);
        p.mPositiveButtonListener = this;
        p.mNegativeButtonText = getString(com.android.internal.R.string.cancel);
        p.mNegativeButtonListener = this;
        setupAlert();
    
protected voidonPause()

        super.onPause();
        
        unregisterReceiver(mStorageReceiver);
    
protected voidonResume()

        super.onResume();

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_MEDIA_REMOVED);
        filter.addAction(Intent.ACTION_MEDIA_CHECKING);
        filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
        filter.addAction(Intent.ACTION_MEDIA_SHARED);
        registerReceiver(mStorageReceiver, filter);