Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Google Plus Page Via Intent In Android

Tags:

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.

like image 351
benoffi7 Avatar asked Aug 08 '12 15:08

benoffi7


1 Answers

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/.

like image 133
Chirag Shah Avatar answered Sep 18 '22 06:09

Chirag Shah