Try to call FACEBOOK

0

The following is this trigger an attempt and the same call the Facebook app. I was able 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.

    
asked by anonymous 11.12.2015 / 09:58

1 answer

2

Facebook is a website and not a native google app, so you have three options:

  • Calling a webview (does not require a Intent necessarily) or using a native browser
  • Calling the facebook app will require the Facebook app to be installed.
  • Using the official API

Try using Facebook app:

As I said, you need to have the application installed, as this soen's answer is soen

  • 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 inbox:

    String uri = "facebook://facebook.com/inbox";
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    startActivity(intent);
    
  • Other screens:

    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 it allows you some more control

  • Sign up link
  • Create an application name
  • API 15: Android 4.0.3 is required at a minimum
  • Create the keys
  • Import% with%
  • Follow the link documentation.

Using the default browser installed

The following code will use the default browser, it may make it easier for the user to use the browser to connect to facebook, as this will probably already be logged (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 com.facebook.FacebookSdk

    
11.12.2015 / 12:43