简体   繁体   English

Android,启动模拟器启动应用程序

[英]Android, Start App on Launch of Emulator

I want to do some testing on the Android emulator to run an app of mine automatically and pass it a parameter how can I do this? 我想在Android模拟器上做一些测试,自动运行我的应用程序并传递参数我该怎么办?

For now lets assume, I have an app that opens a URL (parameter) in a browser. 现在假设,我有一个在浏览器中打开URL(参数)的应用程序。 How can I get my emulator to do this upon launch of app? 如何在启动应用程序时让我的模拟器执行此操作?

This is for testing and this app will not be give to other to be used. 这是用于测试,这个应用程序将不会给其他人使用。

Thanks all 谢谢大家

You want to add the "boot completed" permission, then add an intent for the broadcast and make a broadcastreceiver: 您想要添加“已完成启动”权限,然后为广播添加意图并制作广播接收者:

--in your manifest: - 在你的清单中:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

--and also in the manifest: - 还有清单:

<receiver android:name=".receiver.BootReceiver">
    <intent-filter>
      <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>

--then make a receiver: - 然后做一个接收器:

public class MyBootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
       //use an intent to stat your activity here!   
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM