Google Plus深层链接

时间:2016-09-21 07:35:52

标签: android google-plus deep-linking

我尝试使用google plus与我的应用程序建立深层链接。根据{{​​3}}指南,我为我的应用实施了深层链接。但没有奏效。 在过去的两天里,我根据其他一些例子做了很多尝试来改变我的实现,但仍然没有用。现在我的解决方案看起来像这样:

的AndroidManifest.xml

<activity android:name="com.silkwallpaper.ParseDeepLinkActivity">

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="silk-paints.com" android:host="deeplink"/>
        </intent-filter>
    </activity>

分享到谷歌

  private static final String DEEP_LINK_URL = "silk-paints.com://deeplink/";

  public static void shareGP(final Activity activity, final TrackEntity track) {
    Intent shareIntent = new PlusShare.Builder(activity).addStream(Uri.parse(track.urlShare))
                                                        .setText(DEEP_LINK_URL)
                                                        .setType("text/plain")
                                                        .setContentUrl(Uri.parse(track.urlShare))
                                                        .setContentDeepLinkId(DEEP_LINK_URL)
                                                        .getIntent();

    activity.startActivityForResult(shareIntent, GP_REQUEST_CODE);
  }

但我得到的只是我的Google+信息页中的帖子。点击此帖子不会将我重定向到应用程序。我做错了什么?

1 个答案:

答案 0 :(得分:1)

根据documentation:如果您有可以链接的网络形象,则应该将该网址用于内容网址和深层链接标识符,以便Google可以检索您的代码段数据在共享帖子中使用。
所以你可以试试这个:

AndroidManifest.xml

<intent-filter>
    <action android:name="com.google.android.apps.plus.VIEW_DEEP_LINK" />
    <data android:scheme="vnd.google.deeplink" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

与深层链接共享

Intent shareIntent = new PlusShare.Builder(this)
        .setText("Check out: http://silk-paints.com/")
        .setType("text/plain")
        .setContentUrl(Uri.parse("http://silk-paints.com/"))
        .setContentDeepLinkId("http://silk-paints.com/")
        .getIntent();

startActivityForResult(shareIntent, 0);

还可以查看Handling incoming deep links