33317

Create a mobile app that just points to URL

Question:

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.

Answer1:

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"]];

Answer2:

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.

Recommend

  • UnicodeDecodeError when trying to read docx file
  • What is the difference between .log and .txt?
  • Why use Windows.Forms.Timer at all?
  • How to clone bootstrap multi-select dynamically?
  • Eager Loading with Pagination
  • How to deploy a COM
  • Jaccard Similarity of an RDD with the help of Spark and Scala without Cartesian?
  • Sync two textboxes with different models
  • Java Arithmetic division
  • password_hash() not working [closed]
  • React Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Velocity (VM) template request parameters: Getting GET variables
  • Sharing multiple images on facebook post
  • Hiding prices based on visitor location backend bug in Woocommerce
  • How to read contents of a directory recursively in Linux Kernel?
  • Getting specific color for specific value using JSON data
  • the IBM_JAVA error for running jobs in Hadoop 2.2.0
  • Test for NULLs in multiple columns in MySQL
  • Threads and Concurrent Modification Exception working with a list
  • jQuery colorbox breaks postbacks in ASP.NET Web Forms
  • Getting/building the SQL (with parameters) from NHibernate 3.2
  • Custom Timeline items in Glimpse
  • How can I do case insensitive string search with Linq and SQL Server?
  • how to add dashed border on highcharts “area” graph for every point
  • Run a form (insert/update/delete) from within a div using jquery
  • How to use Typescript with libraries like Ampersand.js that parse configs to build prototypes
  • Java Collections.shuffle() weird behaviour [closed]
  • Set WebClient.Builder.exchangeStrategies() without losing Spring Jackson configuration
  • Java .policy file - how to prevent java.util.Date() from being accessible
  • jQuery scrollTop if URL has hash
  • Background transfer download task failed when app was closed
  • ssh remote server login script
  • Creating random wired topology for given arbitrary number of nodes on NS2
  • No OpKernel was registered to support Op 'Conv2D' with these attrs