Register Application To Launch When USB Item Is Connected To PC
Solution 1:
In your Manifest.xml, add this:
<receiver android:name=".BattStatusShow">
<intent-filter>
<action android:name="android.intent.action.ums_connected" />
</intent-filter>
</receiver>
Then have your battery status class extend BroadcastReceiver, since your registered it for USB messages in the Manifest file.
public class BattStatusShow extends BroadcastReceiver{
if (intent.getAction().equalsIgnoreCase( "android.intent.action.UMS_CONNECTED")) {
//do stuff here, like signal the view of your app it needs to do something
}
}
You don't give much information about what your application, but if it is only a battery display application, programming a PC host application to talk to your Android app seems overkill. If you want to do more, look at how the Nokia PC station app interacts with Nokia and emulate the behavior.
Solution 2:
You can open any application from your mobile even if it is connected to PC via USB.
Visit the below link know about detecting USB connected or detached and Register a Broadcast Receiver for the same and launch your application from the Receiver using appropriate intent.
http://developer.android.com/guide/topics/usb/accessory.html
Post a Comment for "Register Application To Launch When USB Item Is Connected To PC"