Android Question How to eject USB disk

cxbs

Active Member
Licensed User
Longtime User
Hello everyone!

After copying files to the USB disk, if you force the USB disk to be removed, a 0 byte file will be produced. So you want to pop up the USB disk by programming. Here is the source code found on the Internet. I don't know how to convert it to ba4

Hope to get help, thank you!

eject USB Disk:
public void doUnMountU() {
        IMountService service = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
        try {
            service.unmountVolume(App_DataPara.getApp().GetExternalStorageDirectory(), true, false);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

App_DataPara.getApp().GetExternalStorageDirectory() It is the file directory of the U disk that needs to be unloaded. String type
 

cxbs

Active Member
Licensed User
Longtime User
You can call this code with inline java. You will need to find the package names and add them with imports.

Inline Java Code

Hello, Erel
I'm not familiar with Java. I tried to embed Java, but I didn't define imountservice and servicemanager. I tried to use import android.os.ServiceManager; But it still can't be edited
 
Upvote 0
Top