2017-01-16 10 views
0

私はXamarinを使用してAndroidアプリケーションを開発しています。私は、ユーザーがリンクexample://gizmosを開いたときにアプリを開くことができるようにしたいので、私は私のマニフェストファイルにこれを追加します。これはAndroidのドキュメントから直接取得されXamarin Androidディープリンクが動作しない

<activity android:name="mynamespace.MyActivity" 
android:label="@string/application_name" > 
<intent-filter android:label="@string/application_name"> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos” --> 
    <data android:scheme="http" 
     android:host="www.example.com" 
     android:pathPrefix="/gizmos" /> 
    <!-- note that the leading "/" is required for pathPrefix--> 
    <!-- Accepts URIs that begin with "example://gizmos” --> 
    <data android:scheme="example" 
     android:host="gizmos" /> 

</intent-filter> 
</activity> 

。私は私の物理的なAndroidデバイス上のメールアプリケーションからリンクexample://gizmosをクリックしてみてください、私はメッセージが表示されます:Unable to find application to perform this action

EDIT

それは、彼らが使用していない、提案重複と同じではありませんXamarin。 Xamarinで

+0

[ディープリンク意図がヲないの可能性の重複:とあなたのリンクを開きますrk](http://stackoverflow.com/questions/24808777/deep-linking-intent-does-not-work) – Demitrian

+0

重複していません。彼らはXamarinを使用していません。 – Darius

+0

私も同じ問題を抱えています。クラスを取得するのに例外が見つかりませんでした https://stackoverflow.com/questions/48680875/getting-class-not-found-exception-when-doing-deeplinking-in-xamarin-forms –

答えて

2

アクティビティの設定は、例えばアクティビティクラス

の属性に設定されているアンドロイド:う

namespace XamarinAndroidDeepLink 
{ 
    [Activity(Label = "XamarinAndroidDeepLink", MainLauncher = true, Icon = "@drawable/icon")] 
    [IntentFilter(new[] { Android.Content.Intent.ActionView }, 
    DataScheme = "wori", 
    DataHost = "example.com", 
    DataPathPrefix ="/", 
    Categories = new[] { Android.Content.Intent.CategoryDefault,Android.Content.Intent.CategoryBrowsable })] 
    public class MainActivity : Activity 
    { 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      // Set our view from the "main" layout resource 
      SetContentView (Resource.Layout.Main);  
     } 
    } 
} 

そして、あなたはマニフェストでのC#をインテントフィルタを設定する必要はありませんマニフェストで設定をビルドするのに役立ちます。

テストADBがディープリンク:

adb shell am start -W -a android.intent.action.VIEW -d "wori://example.com/?id=1234" XamarinAndroidDeepLink.XamarinAndroidDeepLink 

あなたはアプリの起動を見つける:

enter image description here

いくつかのブラウザは、URLを区別することはできません。顧客のURLの前にhttp://を追加し、アドレスバーにURLを入力すると、検索エンジンを使用します。

私はあなたがあなた自身のhtmlページを設計し、HTMLページを開くには、GoogleのChromeをダウンロードすることをお勧め:

注:HTMLビューアでHTMLページを開けないでください

<html> 
<head> 
    <title>Product 12345</title> 
</head> 
<body> 
    <a href="wori://example.com/?id=1234">lalala</a> 
</body> 
</html> 

のGoogle Chromeをダウンロード

enter image description here

+0

リンクhttp://example.comを開いても機能しません。このために 'Categories'に何かを追加する必要がありますか? – Darius

+1

@Darius私は答えを編集してDataSchemeを "wori"に変更しました。ブラウザで開きます。 HTMLビューアであなたのHTMLページを開かないでください。 –

+0

これは、ありがとう!しかし、私は何か変わったことに気づいた:私はリンクを介してアプリを開くと、別のアプリを開きます(同じアプリを既に開いているのではなく)。これはNexus 5端末でのみ発生します(Galaxy S6で正常に動作します)。私は、このようなアプリを開いたときに、アプリケーションのタイトルが異なること、アセンブリ名(または名前空間)を使用していることに気づいたので、これが理由です。私は(おそらく)これを避けることができるように使用する名前を指定する方法を知っていますか? – Darius

関連する問題