Open Google Plus Page Via Intent In Android

benoffi7 picture benoffi7 · Aug 8, 2012 · Viewed 13.5k times · Source

I have a Google Plus page

https://plus.google.com/u/0/b/101839105638971401281/101839105638971401281/posts

and an Android application. I want to open this page in my app. I don't want to open the browser!

This opens the browser:

URL="https://plus.google.com/b/101839105638971401281/101839105638971401281/posts";
uri = Uri.parse(URL);
it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);

this crashes:

 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);

Thanks in advance!

[SOLVED]

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/101839105638971401281/posts")));

With this solution the user can choose the Google Plus APP or open the browser. If the APP is chosen, there is no crash.

Answer

Chirag Shah picture Chirag Shah · Aug 8, 2012

If the user has the Google+ app installed, you can do this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/101839105638971401281/posts")));

Notice the syntax of the URI, and that it doesn't contain /b/id/.