2
我用下面的代码共享内容(如文字,图像和应用程序的链接)至Facebook:传递参数给Facebook应用链接从Android应用程序
第1步:
public void setupFacebookShareIntent() {
ShareDialog shareDialog;
FacebookSdk.sdkInitialize(getApplicationContext());
shareDialog = new ShareDialog(this);
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(title)
.setContentDescription(
text1+ " " +text2)
.setContentUrl(Uri.parse("http://example/folder"))
.setImageUrl(Uri.parse(path1))
.build();
shareDialog.show(linkContent);
}
另外这里该应用链接的元数据:
步骤2:
<html>
<head>
<meta property="al:android:url" content="sharesample://story/1234">
<meta property="al:android:package" content="com.mypackage">
<meta property="al:android:app_name" content="ShareSample">
<meta property="og:title" content="example page title" />
<meta property="og:type" content="website" />
</head>
<body>
</body>
</html>
而这里的代码来处理活动进入应用程序链接:
第3步:
Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(this, getIntent());
if (targetUrl != null) {
// If you need to access data that you are passing from the meta tag from your website or from opening app you can get them from AppLinkData.
Bundle applinkData = AppLinks.getAppLinkData(getIntent());
String id = applinkData.getString("id");
// You can also get referrer data from AppLinkData
Bundle referrerAppData = applinkData.getBundle("referer_app_link");
} else {
// Not an applink, your existing code goes here.
}
我怎样才能将数据传递给应用程序链接的URL在步骤1中正确,如简单字符串参数然后回到步骤3?
没有人有一个想法? :) – Sin