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.
What does the stack trace say when it crashes?
Also I'm not sure if this would make a difference but there's a typo in the ID. You wrote:
but originally the ID was
101839105638971401281
. You left off the 1 at the end.Why not just
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
. Android OS queries all Applications that can handle a specific Uri. Google+, as an app, is programmed to be able to handle the Uri you are requesting. So it will show up as an option in a chooser (or just go to it if the user has already selected the Google+ app to be default for that Uri.You have to first check that user already has G+ App in his/her phone or not ? If yes then we can start it by specific intent or we can use browser redirection to specific page.
Here's one method in such flow,
Now you can call this method simply like,
Extended Answer : Same way for twitter and facebook you can use,
For Twitter,
And For Facebook,
If the user has the Google+ app installed, you can do this:
Notice the syntax of the URI, and that it doesn't contain
/b/id/
.