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();
}
|
private void | mountAsUsbStorage()
IMountService mountService = IMountService.Stub.asInterface(ServiceManager
.getService("mount"));
if (mountService == null) {
showSharingError();
return;
}
try {
mountService.setMassStorageEnabled(true);
} catch (RemoteException e) {
showSharingError();
return;
}
|
public void | onClick(android.content.DialogInterface dialog, int which){@inheritDoc}
if (which == POSITIVE_BUTTON) {
mountAsUsbStorage();
}
// 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_usb;
p.mTitle = getString(com.android.internal.R.string.usb_storage_title);
p.mMessage = getString(com.android.internal.R.string.usb_storage_message);
p.mPositiveButtonText = getString(com.android.internal.R.string.usb_storage_button_mount);
p.mPositiveButtonListener = this;
p.mNegativeButtonText = getString(com.android.internal.R.string.usb_storage_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 | showSharingError()
Toast.makeText(this, com.android.internal.R.string.usb_storage_error_message,
Toast.LENGTH_LONG).show();
|