简体   繁体   English

手机连接到PC时自动运行应用程序

[英]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.

相关问题 连接Android手机时,使Java应用程序同步PC上的联系人 - making a Java application synchronize the contacts on the PC, when an android phone is connected to it 连接到PC时如何在Android手机上运行Shell命令? - How to run shell commands on Android phone when connected to a PC? 手机SD卡连接到电脑时文件不可见 - File is not visible when phone sd card is connected to pc 注册应用程序以在USB项目连接到PC时启动 - Register application to launch when USB item is connected to PC 选择“传输文件”模式时,连接到PC的电话已崩溃 - The phone which is connected to the PC has crashed when I choose the mode “Transfer files” 正常使用手机(未连接到电脑)时,我能捕获LogCat消息吗? - Can I catch LogCat messages when using the phone normally (not connected to the pc)? 当我的Android手机连接到PC Thorrugh USB时,无法连接到sqlserver - Cannot connect to sqlserver when my android phone is connected to pc thorugh usb 通过蓝牙连接的手机从 PC 拨打电话 - Making call from PC via bluetooth connected mobile phone Android活动/服务仅在手机连接到PC时有效 - android activity/service works only if phone connected to pc Android:如果手机未通过调试模式连接到PC,则蓝牙速度非常慢 - Android: bluetooth is very slow if a phone is not connected to PC with debug mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM