views:

219

answers:

2

I do some mobile browser testing in the Android web browser through the Android SDK in Linux and I have a couple of questions:

  1. Can I run an Android Virtual Device without the entire Android SDK?
  2. Can I autostart the web browser when starting an Android Virtual Device/emulator?
+2  A: 

I'm not sure why you want to do 1), but 2) is possible if you're willing to do a bit of work. You have to create a simple Android app that receives the BOOT_COMPLETED hardware event and then launches the browser. Once this app is installed, your browser will start automatically.

Little background knowledge: How to start an Android project

The app is pretty simple. You need to declare that your app is to digest the BOOT_COMPLETED event. You can do this in the AndroidManifest.xml:

<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>

Then, you just need to implement the BrowserStartupIntentReceiver class. Its only function is to broadcast an intent to the OS to launch the browser.

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);
    }
}

That should launch the browser when the emulator boots up. Though, it might not be worth going to such lengths to avoid the extra button press.

iandisme
A: 

For #2 I don't know, and I assume iandisme's answer is good enough, but for #1 you could always try to run "live-android" (a LiveCD with Android for computers) in a virtual machine.

You can possibly also run Android in the emulator without having to install the whole SDK, but I am not quite sure.

Frxstrem