puedo lite internet gratis funciona entrar desde descargar celular carga abrir abre android facebook url-scheme

lite - Abra la página de Facebook desde la aplicación de Android?



no puedo abrir facebook en mi celular (18)

¿Esto no es más fácil? Por ejemplo, dentro de un OnClickListener?

try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/426253597411506")); startActivity(intent); } catch(Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/appetizerandroid"))); }

PD. Obtenga su identificación (el número grande) de http://graph.facebook.com/[userName]

desde mi aplicación de Android, me gustaría abrir un enlace a un perfil de Facebook en la aplicación oficial de Facebook (si la aplicación está instalada, por supuesto). Para iPhone, existe el esquema de URL fb:// , pero intentar lo mismo en mi dispositivo Android arroja una ActivityNotFoundException .

¿Existe la posibilidad de abrir un perfil de Facebook en la aplicación oficial de Facebook desde el código?


Después de muchas pruebas, encontré una de las soluciones más efectivas:

private void openFacebookApp() { String facebookUrl = "www.facebook.com/XXXXXXXXXX"; String facebookID = "XXXXXXXXX"; try { int versionCode = getActivity().getApplicationContext().getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode; if(!facebookID.isEmpty()) { // open the Facebook app using facebookID (fb://profile/facebookID or fb://page/facebookID) Uri uri = Uri.parse("fb://page/" + facebookID); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } else if (versionCode >= 3002850 && !facebookUrl.isEmpty()) { // open Facebook app using facebook url Uri uri = Uri.parse("fb://facewebmodal/f?href=" + facebookUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } else { // Facebook is not installed. Open the browser Uri uri = Uri.parse(facebookUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } } catch (PackageManager.NameNotFoundException e) { // Facebook is not installed. Open the browser Uri uri = Uri.parse(facebookUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }


En Facebook versión 11.0.0.11.23 (3002850) fb://profile/ y fb://page/ ya no funciona. Descompilé la aplicación de Facebook y descubrí que puedes usar fb://facewebmodal/f?href=[YOUR_FACEBOOK_PAGE] . Este es el método que he estado usando en producción:

/** * <p>Intent to open the official Facebook app. If the Facebook app is not installed then the * default web browser will be used.</p> * * <p>Example usage:</p> * * {@code newFacebookIntent(ctx.getPackageManager(), "https://www.facebook.com/JRummyApps");} * * @param pm * The {@link PackageManager}. You can find this class through {@link * Context#getPackageManager()}. * @param url * The full URL to the Facebook page or profile. * @return An intent that will open the Facebook page/profile. */ public static Intent newFacebookIntent(PackageManager pm, String url) { Uri uri = Uri.parse(url); try { ApplicationInfo applicationInfo = pm.getApplicationInfo("com.facebook.katana", 0); if (applicationInfo.enabled) { // http://.com/a/24547437/1048340 uri = Uri.parse("fb://facewebmodal/f?href=" + url); } } catch (PackageManager.NameNotFoundException ignored) { } return new Intent(Intent.ACTION_VIEW, uri); }


Esta es la manera de hacerlo en 2016, funciona muy bien y es muy fácil.

Descubrí esto después de ver cómo los correos electrónicos enviados por Facebook abrieron la aplicación.

// e.g. if your URL is https://www.facebook.com/EXAMPLE_PAGE, you should put EXAMPLE_PAGE at the end of this URL, after the ? String YourPageURL = "https://www.facebook.com/n/?YOUR_PAGE_NAME"; Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(YourPageURL)); startActivity(browserIntent);


Esto funciona en la última versión:

  1. Vaya a https://graph.facebook.com/ < user_name_here > ( https://graph.facebook.com/fsintents por ejemplo)
  2. Copia tu identificación
  3. Usa este método:

    public static Intent getOpenFacebookIntent(Context context) { try { context.getPackageManager().getPackageInfo("com.facebook.katana", 0); return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/<id_here>")); } catch (Exception e) { return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<user_name_here>")); } }

Esto abrirá la aplicación de Facebook si el usuario lo tiene instalado. De lo contrario, abrirá Facebook en el navegador.

EDITAR: desde la versión 11.0.0.11.23 (3002850) la aplicación de Facebook ya no es compatible, hay otra manera, verifique la respuesta a continuación de Jared Rummler.


Esto ha sido diseñado por Pierre87 con ingeniería inversa en el foro de FrAndroid , pero no puedo encontrar ningún oficial que lo describa, por lo que debe tratarse como no documentado y puede dejar de funcionar en cualquier momento:

Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.facebook.katana", "com.facebook.katana.ProfileTabHostActivity"); intent.putExtra("extra_user_id", "123456789l"); this.startActivity(intent);


Mi respuesta se basa en la respuesta ampliamente aceptada de joaomgcd. Si el usuario tiene Facebook instalado pero deshabilitado (por ejemplo, al usar Cuarentena de aplicaciones), este método no funcionará. Se seleccionará la intención de la aplicación Twitter, pero no podrá procesarla ya que está deshabilitada.

En lugar de:

context.getPackageManager().getPackageInfo("com.facebook.katana", 0); return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/620681997952698"));

Puede usar lo siguiente para decidir qué hacer:

PackageInfo info = context.getPackageManager().getPackageInfo("com.facebook.katana", 0); if(info.applicationInfo.enabled) return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/620681997952698")); else return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/620681997952698"));


Para hacer esto necesitamos la "Identificación de la página de Facebook", puedes obtenerla:

  • de la página vaya a "Acerca de".
  • ve a la sección "Más información".

Para abrir la aplicación de Facebook en la página de perfil especificada,

Puedes hacerlo:

String facebookId = "fb://page/<Facebook Page ID>"; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(facebookId)));

O puede validar cuando la aplicación de Facebook no está instalada, luego abra la página web de Facebook.

String facebookId = "fb://page/<Facebook Page ID>"; String urlPage = "http://www.facebook.com/mypage"; try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(facebookId ))); } catch (Exception e) { Log.e(TAG, "Application not intalled."); //Open url web page. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); }


Para la página de Facebook:

try { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + pageId)); } catch (Exception e) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + pageId)); }

Para el perfil de Facebook:

try { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + profileId)); } catch (Exception e) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + profileId)); }

... porque ninguna de las respuestas señala la diferencia

Ambos probaron con Facebook v.27.0.0.24.15 y Android 5.0.1 en Nexus 4


Puede abrir la aplicación de Facebook con un clic en el botón de la siguiente manera:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startNewActivity("com.facebook.katana"); } }); } public void startNewActivity( String packageName) { Intent intent = MainActivity.this.getPackageManager().getLaunchIntentForPackage(packageName); if (intent != null) { // we found the activity // now start the activity intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { // bring user to the market // or let them choose an app? intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("market://details?id="+packageName)); startActivity(intent); } }


este es el código más simple para hacer esto

public final void launchFacebook() { final String urlFb = "fb://page/"+yourpageid; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(urlFb)); // If a Facebook app is installed, use it. Otherwise, launch // a browser final PackageManager packageManager = getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() == 0) { final String urlBrowser = "https://www.facebook.com/pages/"+pageid; intent.setData(Uri.parse(urlBrowser)); } startActivity(intent); }


prueba este código:

String facebookUrl = "https://www.facebook.com/<id_here>"; try { int versionCode = getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode; if (versionCode >= 3002850) { Uri uri = Uri.parse("fb://facewebmodal/f?href=" + facebookUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } else { Uri uri = Uri.parse("fb://page/<id_here>"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } } catch (PackageManager.NameNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(facebookUrl))); }


"fb://page/ no funciona con las versiones más recientes de la aplicación FB. Debe usar fb://facewebmodal/f?href= para las versiones más recientes.

Este es un código de trabajo completo:

public static String FACEBOOK_URL = "https://www.facebook.com/YourPageName"; public static String FACEBOOK_PAGE_ID = "YourPageName"; //method to get the right URL to use in the intent public String getFacebookPageURL(Context context) { PackageManager packageManager = context.getPackageManager(); try { int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode; if (versionCode >= 3002850) { //newer versions of fb app return "fb://facewebmodal/f?href=" + FACEBOOK_URL; } else { //older versions of fb app return "fb://page/" + FACEBOOK_PAGE_ID; } } catch (PackageManager.NameNotFoundException e) { return FACEBOOK_URL; //normal web url } }

Este método devolverá la URL correcta para la aplicación si está instalada o la URL web si la aplicación no está instalada.

Luego comience una intención de la siguiente manera:

Intent facebookIntent = new Intent(Intent.ACTION_VIEW); String facebookUrl = getFacebookPageURL(this); facebookIntent.setData(Uri.parse(facebookUrl)); startActivity(facebookIntent);


La mejor respuesta que he encontrado, está funcionando muy bien.

Simplemente vaya a su página en Facebook en el navegador, haga clic derecho, y haga clic en "Ver código fuente", luego encuentre el atributo page_id : debe usar page_id aquí en esta línea después de la última barra invertida:

fb://page/pageID

Por ejemplo:

Intent facebookAppIntent; try { facebookAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/1883727135173361")); startActivity(facebookAppIntent); } catch (ActivityNotFoundException e) { facebookAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://facebook.com/CryOut-RadioTv-1883727135173361")); startActivity(facebookAppIntent); }


He creado un método para abrir la página de Facebook en la aplicación de Facebook, si la aplicación no existe y luego se abre en Chrome

String socailLink="https://www.facebook.com/kfc"; Intent intent = new Intent(Intent.ACTION_VIEW); String facebookUrl = Utils.getFacebookUrl(getActivity(), socailLink); if (facebookUrl == null || facebookUrl.length() == 0) { Log.d("facebook Url", " is coming as " + facebookUrl); return; } intent.setData(Uri.parse(facebookUrl)); startActivity(intent);

Utils.class agrega este método

public static String getFacebookUrl(FragmentActivity activity, String facebook_url) { if (activity == null || activity.isFinishing()) return null; PackageManager packageManager = activity.getPackageManager(); try { int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode; if (versionCode >= 3002850) { //newer versions of fb app Log.d("facebook api", "new"); return "fb://facewebmodal/f?href=" + facebook_url; } else { //older versions of fb app Log.d("facebook api", "old"); return "fb://page/" + splitUrl(activity, facebook_url); } } catch (PackageManager.NameNotFoundException e) { Log.d("facebook api", "exception"); return facebook_url; //normal web url } }

y esto

/*** * this method used to get the facebook profile name only , this method split domain into two part index 0 contains https://www.facebook.com and index 1 contains after / part * @param context contain context * @param url contains facebook url like https://www.facebook.com/kfc * @return if it successfully split then return "kfc" * * if exception in splitting then return "https://www.facebook.com/kfc" * */ public static String splitUrl(Context context, String url) { if (context == null) return null; Log.d("Split string: ", url + " "); try { String splittedUrl[] = url.split(".com/"); Log.d("Split string: ", splittedUrl[1] + " "); return splittedUrl.length == 2 ? splittedUrl[1] : url; } catch (Exception ex) { return url; } }


Un enfoque más reutilizable.

Esta es una funcionalidad que generalmente usamos en la mayoría de nuestras aplicaciones. Por lo tanto, aquí hay una pieza de código reutilizable para lograr esto.

(Similar a otras respuestas en términos de hechos. Publicarlo aquí solo para simplificar y hacer que la implementación sea reutilizable)

"fb://page/ no funciona con las versiones más recientes de la aplicación FB. Debe usar fb://facewebmodal/f?href= para versiones más recientes. ( Como se menciona en otra respuesta aquí )

Este es un código de trabajo completo actualmente en vivo en una de mis aplicaciones:

public static String FACEBOOK_URL = "https://www.facebook.com/YourPageName"; public static String FACEBOOK_PAGE_ID = "YourPageName"; //method to get the right URL to use in the intent public String getFacebookPageURL(Context context) { PackageManager packageManager = context.getPackageManager(); try { int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode; if (versionCode >= 3002850) { //newer versions of fb app return "fb://facewebmodal/f?href=" + FACEBOOK_URL; } else { //older versions of fb app return "fb://page/" + FACEBOOK_PAGE_ID; } } catch (PackageManager.NameNotFoundException e) { return FACEBOOK_URL; //normal web url } }

Este método devolverá la URL correcta para la aplicación si está instalada o la URL web si la aplicación no está instalada.

Luego comience una intención de la siguiente manera:

Intent facebookIntent = new Intent(Intent.ACTION_VIEW); String facebookUrl = getFacebookPageURL(this); facebookIntent.setData(Uri.parse(facebookUrl)); startActivity(facebookIntent);

Eso es todo lo que necesitas.


Intent intent = null; try { getPackageManager().getPackageInfo("com.facebook.katana", 0); String url = "https://www.facebook.com/"+idFacebook; intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href="+url)); } catch (Exception e) { // no Facebook app, revert to browser String url = "https://facebook.com/"+idFacebook; intent = new Intent(Intent.ACTION_VIEW); intent .setData(Uri.parse(url)); } this.startActivity(intent);


try { String[] parts = url.split("//www.facebook.com/profile.php?id="); getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent (Intent.ACTION_VIEW, Uri.parse(String.format("fb://page/%s", parts[1].trim())))); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); }