Friday, February 25, 2011

Create web site launcher in Android

In this tutorial we will try to create a simple application to launch specific web address. Like a shortcut, this application will call another android application and launch it, in this case will launch default browser and open specific web address.

We will use the power of Android Intent. Here is example of the code:

package tnto.info.android.sitelauncher;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class SiteLauncher extends Activity {

Intent intent;
public SiteLauncher(){
String webAddress="http://ipb.ac.id";
intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(webAddress));
}
/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

startActivity(intent);

finish();
}
}

3 comments:

  1. hemm... how to add icon for this programm???

    ReplyDelete
  2. Hi! my rank is Jully. I would like to meemeet good boy :)
    This is my homepage [url=]http://jskdh5jkd7djh4.com/[/url]l

    ReplyDelete
  3. Hi! my rank is Jully. I would like to meemeet admissible boy :)
    This is my homepage [url=]http://jskdh5jkd7djh4.com/[/url]l

    ReplyDelete