Jump to content

Creating a Weblink on an App - Help please

Spaceship's Photo
Posted Mar 15 2010 06:12 AM
1349 Views

Hi,

I am new to Android development and am creating an App which links to a URL but am having difficulty. I have created a buttin which I want to connect to the URL when it is clicked. Can you give me any advice for sample codes as I must be missing something out as I can't get it to connect.

Thanks,

Sam.

Tags:
0 Subscribe


1 Reply

+ 2
  thillerson's Photo
Posted Mar 15 2010 08:30 AM

try this:

button.setOnClickListener(new View.OnClickListener() {
  public void onClick(View v) {
    // replace your url here:
    String url = "http://google.com";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);
  }
});