应用程序链接不适用于Android上的Facebook
问题描述:
Facebook应用程序链接无法正常工作。链接包含以下内容:应用程序链接不适用于Android上的Facebook
<html>
<head>
<meta property="al:android:url" content="myapp://12345" />
<meta property="al:android:package" content="com.my.app" />
<meta property="al:android:app_name" content="myApp" />
<meta property="al:web:should_fallback" content="false" />
</head>
</html>
Androidmanifest是这样的:
<activity
android:name="com.my.app.MyAppActivity"
android:launchMode="singleTask"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="myapp" />
</intent-filter>
在HTML
元属性应该是负责从Facebook应用程序启动意图,但通过Facebook开放的链接不启动应用程序。 我哪里错了?
答
此应用链接如何帮助我通过Facebook或其他共享意向与朋友分享。
分享意向代码
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Lets Enjoy");
intent.putExtra(Intent.EXTRA_TEXT, "Lets Enjoy" + "http://myApp.com/id/"+12345);
startActivity(Intent.createChooser(intent, "Share With Friends"));
Android清单。
<activity
android:name="com.package.youractivitytoopen"
android:theme="@style/MyMaterialTheme"
android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="myApp.com"
android:pathPrefix="/id/" ></data>
</intent-filter>
</activity>
如果您共享数据,那么你会得到这样的
Intent intentShare = getIntent();
String action = intentShare.getAction();
Uri data = intentShare.getData();
if(data!=null) {
String url = data.toString();
String[] separated = url.split("/");
id= Integer.parseInt(separated[4]);
}
分享通过份额的意图你的朋友的数据,如果他们的应用程序,它会显示选项和应用程序打开,并在活动开你在清单中设置。
https://developer.android.com/training/app-indexing/deep-linking.html
我们可以在Facebook上发布链接。但我们想要的是,当在Facebook上点击链接时,Android应用程序应该打开。 –
这段代码将工作,它会打开应用程序,当你点击链接。 @RakeshAgarwal –