Intent to call FACEBOOK

Asked

Viewed 1,859 times

0

The following is this shoot an Internet and the same call the Facebook app. I managed to send email

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("plain/text");
sendIntent.setData(Uri.parse("[email protected]"));
sendIntent.setClassName("com.google.android.gm", "com.google.android.gm"); sendIntent.putExtra(Intent.EXTRA_EMAIL, new
String[]{"[email protected]"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "ASSUNTO");
sendIntent.putExtra(Intent.EXTRA_TEXT, "TEEEXTO");
startActivity(sendIntent);

Could you adapt this code to call the face app? Thanks in advance.

1 answer

2


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

  • 1

    That’s what it was! Wooow!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.