Open Google Plus Page Via Intent In Android

前端 未结 6 1255
情书的邮戳
情书的邮戳 2020-12-13 19:53

I have a Google Plus page

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

and an Android application.

6条回答
  •  隐瞒了意图╮
    2020-12-13 20:26

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

    Example usage:
    * newGooglePlusIntent(context.getPackageManager(), "https://plus.google.com/+JaredRummler"); * * @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; }

提交回复
热议问题