我在Linux中通过Android SDK在Android Web浏览器上进行一些移动浏览器测试,有几个问题:
- 我能否在没有整个Android SDK的情况下运行Android虚拟设备?
- 我能否在启动Android虚拟设备/模拟器时自动启动Web浏览器?
我在Linux中通过Android SDK在Android Web浏览器上进行一些移动浏览器测试,有几个问题:
<application>
...
<receiver class=".BrowserStartupIntentReceiver">
<intent-filter>
<action android:value="android.intent.action.BOOT_COMPLETED" />
<category android:value="android.intent.category.HOME" />
</intent-filter>
</receiver>
</application>
接下来,您只需要实现BrowserStartupIntentReceiver类。它唯一的功能是向操作系统广播一个意图,以启动浏览器。
public class BrowserStartupIntentReceiver extends IntentReceiver {
@Override
public void onReceiveIntent(Context context, Intent intent) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
myIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
context.startActivity(myStarterIntent);
}
}
当模拟器启动时,这应该会启动浏览器。不过,为了避免多按一个按钮可能并不值得这么做。