Android: how to create a launcher

I have never developed for Android before, so please think that I'm 100% dumb when you answer :)

I would like to create an application launcher that will open the default web browser for the given URL. In other words, I want to create an icon with the logo of my site, and when you click on it, it will open the site in your browser by default.

Can someone direct me to the tutorial / documentation page to achieve this? Or, if it's really simple, maybe show me the code here?

Thank you for your time!

R

+7
source share
4 answers

If I understand correctly what you need, you can simply create a simple application in just 1 action and paste it into onCreate:

Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.yourwebsite.com")); startActivity(viewIntent); 

And here are some resources for creating a simple application:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/HelloWorld.html

And here is the information on how you can install the icon of your application:

http://www.connorgarvey.com/blog/?p=97

+9
source

I wrote a tutorial just for this: = D

http://www.anddev.org/code-snippets-for-android-f33/button-to-open-web-browser-t48534.html

Modified Version:

 package com.blundell.twitterlink; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; public class Main extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sendToTwitter(); // Open the browser finish(); // Close this launcher app } protected void sendToTwitter() { String url = "http://twitter.com/blundell_apps"; // You could have this at the top of the class as a constant, or pass it in as a method variable, if you wish to send to multiple websites Intent i = new Intent(Intent.ACTION_VIEW); // Create a new intent - stating you want to 'view something' i.setData(Uri.parse(url)); // Add the url data (allowing android to realise you want to open the browser) startActivity(i); // Go go go! } } 
+1
source

One line response

 startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url))); 
0
source

Why do you want to create an application for this? You can simply create a shortcut directly on the main screen.

Here's what to do:
1. Go to the site in your browser
2. Add bookmark for the site (menu, add bookmark)
3. Go to the main screen where you want the logo 4. Press and hold the screen when the menu appears, select "add shortcut"
5. Select "bookmarks"
6. Find the bookmark you just created and click on it.

You are done!

-2
source

All Articles