[英]App link not working for facebook on 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中的meta屬性應負責從Facebook應用程序啟動意圖,但通過Facebook打開鏈接不會啟動該應用程序。 我哪里出錯了?
這樣一來,App Link就可以幫助我通過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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.