Saturday, June 2, 2012

View site in a new Window(Browser) in Android

Hello ,
Ever thought to include a feature in your application where user clicks a link of certain site or your personal website in the about section of the application and it opens the site in a window and when user finished viewing your achievement and clicks back button your application again gets displayed.
We are going to perform this in just two lines.
  • So first we have to create a intent.
As we already know intent is an abstract description of an operation to be performed.
So we are going to use another version of intent which has following format.
public Intent(String action,Uri uri)
action is the action we intent(i.e the action we want to perform).
uri is the URL on which the above action is to be performed.

create and intent as

Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse(""));
The above intents means that we want the system to perform a View Action on uri “” (i.e. To view it).
  • Next start this activity as:
  • The site will open in browser as
Site opens in a new window(browser)
Site opens in a new window(browser)

No comments:

Post a Comment