Methods Summary |
---|
private void | handleBatteryChanged(android.content.Intent intent)
int pluggedType = intent.getIntExtra("plugged", 0);
if (pluggedType == 0) {
// It was disconnected from the plug, so finish
finish();
}
|
public void | onClick(android.content.DialogInterface dialog, int which){@inheritDoc}
if (which == POSITIVE_BUTTON) {
stopUsbStorage();
}
// No matter what, finish the activity
finish();
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// Set up the "dialog"
final AlertController.AlertParams p = mAlertParams;
p.mIconId = com.android.internal.R.drawable.ic_dialog_alert;
p.mTitle = getString(com.android.internal.R.string.usb_storage_stop_title);
p.mMessage = getString(com.android.internal.R.string.usb_storage_stop_message);
p.mPositiveButtonText = getString(com.android.internal.R.string.usb_storage_stop_button_mount);
p.mPositiveButtonListener = this;
p.mNegativeButtonText = getString(com.android.internal.R.string.usb_storage_stop_button_unmount);
p.mNegativeButtonListener = this;
setupAlert();
|
protected void | onPause()
super.onPause();
unregisterReceiver(mBatteryReceiver);
|
protected void | onResume()
super.onResume();
registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
private void | showStoppingError()
Toast.makeText(this, com.android.internal.R.string.usb_storage_stop_error_message,
Toast.LENGTH_LONG).show();
|
private void | stopUsbStorage()
IMountService mountService = IMountService.Stub.asInterface(ServiceManager
.getService("mount"));
if (mountService == null) {
showStoppingError();
return;
}
try {
mountService.setMassStorageEnabled(false);
} catch (RemoteException e) {
showStoppingError();
return;
}
|