18

カスタム URL スキームに関する Q&A のほとんどを調査しましたが、考えられる答えが見つかりませんでした。

ブラウザー (モバイル デバイス上のいずれか) で特定の URL をクリックしてアプリを起動したいのですが、IOS アプリも提供しているため、指定された URL を変更することはできず、次のようになります。

"myapp:// http://www.name.com/path/path2/ "

"myapp://http://" を処理して適切なインテント フィルターを作成する方法がわかりません。試したすべてが機能しません。関連する回答を見逃した場合は、謝罪を除いてください。

これは私がこれまでに試したことです:

      <activity
        android:name="com.myapp.test.SplashScreen"
        android:exported="true"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <!-- Test for URL scheme -->
        <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:host="www.name.com"
                android:path="/path/path2/"
                android:scheme="http" />
            <data
                android:host="www.name.com"
                android:path="/path/path2/"
                android:scheme="https" />

            <data android:scheme="myapp" />
        </intent-filter>
        <!-- End Test for URL scheme -->
    </activity>

注: export:true の有無にかかわらず試してみました

4

3 に答える 3

14

CommonsWare が言ったように、スキームを作成する必要があるときに指定された URI は有効な URI ではないため、スキームは機能せず、アプリケーションは起動しませんでした。この説明の後、サーバー側の担当者は URI を myapp://... に変更することを確信し、魔法のように機能しました :)。

アクティビティは次のようになります。

 <activity
    android:name="com.myapp.test.SplashScreen"
    android:exported="true"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <!-- Test for URL scheme -->
    <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>
    <!-- End Test for URL scheme -->
</activity>
于 2013-08-08T12:05:00.873 に答える