Saturday, July 3, 2010

[android-developers] How to find if the device is connected via USB.

Hi All,

How can i find out if my device is already connected via USB.Is there
a way i can do it in code just the way i can check network
connectivity using ConnectivityManager. ??
I was able to broadcast my "USB connected intent" and receive it,but
was struggling to check if the device is already connected or not.

public class Startnext extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent intent) {
CharSequence text = "USB connected";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();

}

}


Please help in this regard if anyone has an idea about it.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment