2016-07-29 70 views
0

我目前正在開發一個Xamarin Forms的應用程序,我希望能夠從一個簡單的URL打開。網址來打開Android應用程序

在iOS上,這部分工作正常,但在Android上我沒有反應,當我嘗試從chrome到達我的網址時。

這裏是我的MainActivity:

【活動(標籤= 「保險箱」,圖標= 「@繪製/標誌」,主題= 「@風格/ MyTheme的」,MainLauncher = TRUE,ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)

[IntentFilter(new[] { Android.Content.Intent.ActionView }, 
       DataScheme = "http", 
       DataHost = "random.com", 
       DataPathPrefix = "/test", 
       Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })] 
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     TabLayoutResource = Resource.Layout.Tabbar; 
     ToolbarResource = Resource.Layout.Toolbar; 

     base.OnCreate(bundle); 

     UserDialogs.Init(this); 

     global::Xamarin.Forms.Forms.Init(this, bundle); 

     App _app = new App(); 
     LoadApplication(_app); 

     if (Intent.HasExtra("al_applink_data")) 
     { 

      var appLinkData = Intent.GetStringExtra("al_applink_data"); 

      var alUrl = new Rivets.AppLinkUrl(Intent.Data.ToString(), appLinkData); 

      // InputQueryParameters will contain our product id 
      if (alUrl != null && alUrl.InputQueryParameters.ContainsKey("id")) 
      { 
       var id = alUrl.InputQueryParameters["id"]; 
       NavigationPage nav = _app.MainPage as NavigationPage; 
       InputPage page = nav.Navigation.NavigationStack[0] as InputPage; 
       page.GenerateContentFromUri(id); 
      } 
     } 
    } 
} 

當我嘗試從Chrome應用達到http://random.com/test URL這通常應該提出從應用中打開的鏈接要麼或繼續鉻,但什麼也沒發生,它只是給網站就好像意向過濾器被忽略了一樣。

你們知道我可能會錯過什麼嗎?

回答

1

沒關係,一切都很好,我只是試圖直接在Chrome導航欄中輸入我的網址。

要從URL打開應用程序,它應該通過點擊鏈接,使其工作

+0

這是正確的完成,而Chrome的一個已知的「功能」。詳情請看這裏:https://bugs.chromium.org/p/chromium/issues/detail?id = 484815 –

相關問題