Facebook is a website and not a native google app, so you have three options:
- Call a webView (you don’t need a webView
Intent
necessarily) or using native browser
- Calling the facebook app will require the facebook app to be installed.
- Using the official API
Intent with Facebook app:
As I said it is necessary to have the application installed as this soen’s response
Just to start the default screen:
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
To start the Inbox:
String uri = "facebook://facebook.com/inbox";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
Other canvas:
facebook://facebook.com/inbox
facebook://facebook.com/info?user=544410940 (id do usuário, somente numeros)
facebook://facebook.com/wall
facebook://facebook.com/wall?user=544410940 (irá mostrar apenas informações visiveis para amigos, caso contrário redireciona para outro activity)
facebook://facebook.com/notifications
facebook://facebook.com/photos
facebook://facebook.com/album
facebook://facebook.com/photo
facebook://facebook.com/newsfeed
Using the official package
This is more complicated, but allows you some more control
Using the standard browser installed
The following code will use the default browser, can facilitate if the user uses the browser to connect to facebook, so it will probably already be logged in (not tested)
Uri uri = Uri.parse("http://www.facebook.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Using webView
The following code will use webView:
WebView webview = new WebView(this);
webview.getSettings().setJavaScriptEnabled(true);
setContentView(webview);
...
webview.loadUrl("http://facebook.com/");
In this case you can use the javascript interface to detect events or trigger events, just use addJavascriptInterface
That’s what it was! Wooow!
– Renatão Alves