[英]Autorun application when phone connected to pc
Is there a way to open an application from dekstop pc (such as an autorun) when the Android device is connected to pc? 当Android设备连接到pc时,是否可以通过dekstop pc打开应用程序(例如自动运行)?
Say that I have been creating an Android Application, and then the application is installed in my Android device (phone / tablet). 假设我一直在创建一个Android应用程序,然后将该应用程序安装在我的Android设备(手机/平板电脑)中。 And I want to give this application a special authority that will let the device to run the app automatically when the device is connected to pc. 我想授予此应用程序特殊权限,该权限将允许该设备在设备连接到PC时自动运行该应用程序。
Actually, the command that will be run by this app is only a command to open a web browser. 实际上,此应用程序将运行的命令仅是打开Web浏览器的命令。
My question is: 我的问题是:
How to give this application a special authority that will let the device to run the app automatically when the device is connected to pc? 如何授予此应用程序特殊的权限,该权限将在设备连接到PC时让设备自动运行该应用程序?
Can someone give me a lighten? 有人可以给我减轻吗?
Many thanks in advance! 提前谢谢了!
You can register broadcast receiver that will wait for example for battery change state broadcast (see this: http://developer.android.com/training/monitoring-device-state/battery-monitoring.html ). 您可以注册广播接收器,以等待例如电池更换状态广播(请参阅: http : //developer.android.com/training/monitoring-device-state/battery-monitoring.html )。 When such broadcast is received, determine if you are connected to PC and start proper activity. 收到此类广播后,请确定您是否已连接到PC并开始适当的活动。
I guess that you might need your application to work all time (have started sticky service) to make this work. 我猜想您可能需要您的应用程序一直工作(已启动粘性服务)才能使其正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.