Jump to content

Detectar PenUSB


a3deluxe

Recommended Posts

Bom dia,

Precisava de uma ajudinha, queria colocar no meu programa

uma pen USB para abrir uma determinada janela,

Quando coloca-se a pen drive ele abrir a janela

com.gambling.h.CredScreen

Quando retira-se a pen drive abria a janela

com.gambling.h.MainActivity

--------------------------------------------------------------------

coloquei este mas não funcionou:

//String path = "/mnt/sdcard/result.xml";

String path = "/mnt/usb_storage/result.xml";

File file2 = new File(path);

if (null != file2)

{

if(file2.exists())

{

<activity android:name="com.gambling.h.CredScreen" />

}

else

{

<activity android:name="com.gambling.h.MainActivity" />

}

}

Mas queria usar outro método, porque este método procura na directoria especifica,

isto não é bom porque se for para instalar a vários tablat não funciona porque as directorias da usb variam consoante

o tablet.

Queria por exemplo fazer como em VB.net, procura pela pen drive.

não usa directório ou Letra da unidade.(exemplo em baixo)

Dim encontrou As Boolean = False

For Each drive As DriveInfo In DriveInfo.GetDrives()

If File.Exists(String.Format("{0}file.txt", drive.Name)) Then

form1.Show()

End If

Next

If Not encontrou Then

form1.Close()

End If

Obrigado

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.