2016-11-24 112 views
0

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開放的鏈接不啓動應用程序。 我哪裏錯了?

回答

0

此應用鏈接如何幫助我通過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

+0

我們可以在Facebook上發佈鏈接。但我們想要的是,當在Facebook上點擊鏈接時,Android應用程序應該打開。 –

+0

這段代碼將工作,它會打開應用程序,當你點擊鏈接。 @RakeshAgarwal –

相關問題