Reputation: 21
This might sound little easy but unfortunately I couldn't find any tutorial. I am trying to make a simple mobile app (iOS and Android) where if u click the icon it opens a URL in mobile browser.
Is there an easy way I can do this an app that just installs icon and that icon when clicked open URL in mobile browser.
PS. I know bookmark option but I would like to have it as an app.
Thank you.
Upvotes: 2
Views: 2018
Reputation: 5246
I'm not sure of the point, however I guess the following would work. You'd still have your app running in the background, as that is how Android lifecycle works.
So, I'd go ahead and create your default application with a 'blank' activity. Once done, all you'd have to do, is ensure that you launch the browser intent when the app is created. I haven't tested this code, but I'm sure it'll work (with little to no debugging):
You need to specify the url to browse to:
Uri urlToBrowse = Uri.parse("YOUR_URL_GOES_HERE");
Then you will need to create an intent for the browser:
Intent browser = new Intent(Intent.ACTION_VIEW, urlToBrowse);
Finally you'll need to start the new activity:
startActivity(browser);
Other than that, you'll have to play about with it. A little more information would have been wonderful, but this should get you started at least.
Upvotes: 1
Reputation: 755
This is how you do it for android
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
context.startActivity(browserIntent);
This is how you do it for iOS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
Upvotes: 5