应用程序链接不适用于Android上的Facebook [英] App link not working for facebook on android
问题描述
< html>
< head>
< meta property =al:android:urlcontent =myapp:// 12345/>
< meta property =al:android:packagecontent =com.my.app/>
< meta property =al:android:app_namecontent =myApp/>
< meta property =al:web:should_fallbackcontent =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打开链接不启动应用程序。
我在哪里出错?
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,与朋友分享));
Android Manifest。
< 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(separate [4]);
}
通过分享意向与您的朋友分享,如果他们有应用程序将显示选项打开应用程序并在您在清单中设置的活动中打开。
https://developer.android.com/training/app-indexing/deep-linking.html
Facebook app link is not working. link contains the following:
<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 is like the following:
<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>
Meta property in the html should be responsible for launching intent from the Facebook app but opening the link through facebook doesn't launch the application. Where I am getting wrong?
This how App Link working for me to share with friends via Facebook or other sharing intent.
Share Intent Code
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 Manifest.
<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>
If you sharing data then you will get data like that
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]);
}
Share with your friends via share intent if they have application it will show option to open with app and opened at the activity you set in manifest.
https://developer.android.com/training/app-indexing/deep-linking.html
这篇关于应用程序链接不适用于Android上的Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!