I want to navigate to a facebook fan page when I click on a button in my adroid application. I am new to android. Can anybody help me to do this.
Asked
Active
Viewed 5,371 times
1
-
possible duplicate of [Android: Sending an Intent to Browser to open specific URL](http://stackoverflow.com/questions/3004515/android-sending-an-intent-to-browser-to-open-specific-url) – Praveenkumar Oct 12 '12 at 07:13
-
Have you tried anyone of the answer? – Praveenkumar Oct 12 '12 at 07:24
3 Answers
5
Why don't you try like this.
String url = "http://www.facebook.com/yourfanpagename";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Place above code inside of your button click.

Praveenkumar
- 24,084
- 23
- 95
- 173
1
Just use intents for it. Here is an example,
In your button's click event:
// Open Website
Intent intent;
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/yourPage"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (Exception e) {
Log.e("Exception Caught", e.toString());
}
Hope this helps!!

Amit Jayant
- 2,501
- 2
- 29
- 38
1
You can do it in two ways:
Using intent to open the browser, like this:
String url = "http://www.facebook.com/your_page"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i);
Use a webview in your layout and open a link in application.It is more preferable.
You can find the link here to implement it.

Martijn Pieters
- 1,048,767
- 296
- 4,058
- 3,343

AppMobiGurmeet
- 719
- 3
- 6