Abrir Google Plus Página Via Intent en Android
Tengo una página de Google Plus
Https://plus.google.com/u/0/b/101839105638971401281/101839105638971401281/posts
- La fuerza de la aplicación se cierra cuando google + no está instalado
- Abrir página en Facebook, Twitter y Google Plus desde otra aplicación - Android
- Android Google + integración a veces devuelve valores nulos
- Cómo obtener amigos de Google+ en Android
- Android integra google + en la aplicación
Y una aplicación de Android. Quiero abrir esta página en mi aplicación. ¡No quiero abrir el navegador!
Esto abre el navegador:
URL="https://plus.google.com/b/101839105638971401281/101839105638971401281/posts"; uri = Uri.parse(URL); it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it);
Esto se bloquea:
Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.google.android.apps.plus", "com.google.android.apps.plus.phone.UrlGatewayActivity"); intent.putExtra("customAppUri", "10183910563897140128"); startActivity(intent);
¡Gracias por adelantado!
[SOLUCIONADO]
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/101839105638971401281/posts")));
Con esta solución, el usuario puede elegir la aplicación de Google Plus o abrir el navegador. Si se elige la APP, no se producirá un bloqueo.
- Android google + login en un fragmento
- ¿Cómo utilizar correctamente Google Plus Iniciar sesión con múltiples actividades?
- Android Google Plus getCurrentPerson devuelve null
- SDK de Google Plus para Android: "Actividad iniciada sin un EXTRA_ACCOUNT"
- Inicio de sesión de Android con Google Plus en el primer inicio de sesión
- Obtener acceso a token de google más Android
- Android - cómo configurar el texto para el botón de inicio de sesión de google + después de autenticado
- Android: falla el estado de la cuenta de Google+ y se bloquea Google Play Services
Si el usuario tiene instalada la aplicación Google+, puede hacerlo:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/101839105638971401281/posts")));
Observe la sintaxis del URI, y que no contiene /b/id/
.
Usted tiene que comprobar primero que el usuario ya tiene G + App en su teléfono o no? En caso afirmativo, podemos iniciarlo por intención específica o podemos usar la redirección del navegador a una página específica.
Aquí hay un método en tal flujo,
public void openGPlus(String profile) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.google.android.apps.plus", "com.google.android.apps.plus.phone.UrlGatewayActivity"); intent.putExtra("customAppUri", profile); startActivity(intent); } catch(ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/"+profile+"/posts"))); } }
Ahora usted puede llamar a este método simplemente como,
//117004778634926368759 is my google plus id openGPlus("117004778634926368759");
Respuesta extendida : De la misma manera para twitter y facebook que puede utilizar ,
Para Twitter ,
public void openTwtr(String twtrName) { try { startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("twitter://user?screen_name=" + twtrName))); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("https://twitter.com/#!/" + twtrName))); } }
Y para Facebook ,
public void openFB(String facebookId) { try{ String facebookScheme = "fb://profile/" + facebookId; Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme)); startActivity(facebookIntent); } catch (ActivityNotFoundException e) { Intent facebookIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.facebook.com/profile.php?id="+facebookId)); startActivity(facebookIntent); } }
/** * Intent to open the official Google+ app to the user's profile. If the Google+ app is not * installed then the Web Browser will be used. * * </br></br>Example usage:</br> * <code>newGooglePlusIntent(context.getPackageManager(), "https://plus.google.com/+JaredRummler");</code> * * @param pm * The {@link PackageManager}. * @param url * The URL to the user's Google+ profile. * @return The intent to open the Google+ app to the user's profile. */ public static Intent newGooglePlusIntent(PackageManager pm, String url) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); try { if (pm.getPackageInfo("com.google.android.apps.plus", 0) != null) { intent.setPackage("com.google.android.apps.plus"); } } catch (NameNotFoundException e) { } return intent; }
¿Qué dice la pila de seguimiento cuando se bloquea?
También no estoy seguro si esto haría una diferencia, pero hay un error tipográfico en la identificación. Tu escribiste:
intent.putExtra("customAppUri", "10183910563897140128");
Pero originalmente el ID era 101839105638971401281
. Dejaste el 1 al final.
¿Por qué no sólo Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
. El sistema operativo Android consulta todas las aplicaciones que pueden gestionar un Uri específico. Google+, como una aplicación, está programada para poder manejar el Uri que está solicitando. Por lo tanto, se mostrará como una opción en un selector (o simplemente ir a él si el usuario ya ha seleccionado la aplicación de Google + por defecto para ese Uri.
- Subir un archivo grande en varias partes usando OkHttp
- ¿Cómo hacer que el teléfono Android sea un auricular bluetooth?