FileDocCategorySizeDatePackage
ExternalMediaFormatActivity.javaAPI DocAndroid 1.5 API4062Wed May 06 22:41:56 BST 2009com.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) {
            IMountService mountService = IMountService.Stub.asInterface(ServiceManager
                .getService("mount"));
            if (mountService != null) {
                try {
                    mountService.formatMedia(Environment.getExternalStorageDirectory().toString());
                } catch (RemoteException e) {
                }
            }
        }

        // 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.mIconId = com.android.internal.R.drawable.stat_sys_warning;
        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);