How to switch to Android USB storage activity?

I would like to get USB Mass Storage activity to enable or disable USB mode when the device is connected to pc.I implemented the application as follows.

public class USB_ConnectActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final String state = Environment.getExternalStorageState(); ((Button)findViewById(R.id.onButton)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!(Environment.MEDIA_SHARED.equals(state))) { //How to navigate android USB Mass Storage page } } }); ((Button)findViewById(R.id.offButton)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if ((Environment.MEDIA_SHARED.equals(state))) { //How to navigate android USB Mass Storage page } } }); } } 

from the above code, I used two buttons to turn off and mass storage of usb. But I have no more information about it for navigating android on the built-in USB Mass Storage page. Please, any body will help me.

+8
android navigation usb-mass-storage
source share
2 answers

If you only want to start USB Activity Mass Storage , then your question will be an exact duplicate: Android Intent to open Mass Storage Activity and should be closed.

If you really want to change the status of the USB mode as it looks, then this is not a duplicate (as far as I can tell), but the answer is still: you cannot do it.

Maybe there is a better way, but when I want to know what intentions are available to trigger system actions, I look at the Android SDK documentation for Intent and find the “action action”. This shows you a lot of system actions that you can run, for example, “use a battery” Activity and removing an Activity . There is nothing there, showing the USB Activity mode as a public Intent . Excusing the pun, it was probably deliberate.

And there is no documentation I can find about any way to programmatically turn USB mode on or off, and this is also supposedly intentional.

+1
source share

This is not possible from the Android SDK.

+1
source share

All Articles