当我在地址栏中输入"myapp://"时,如何从Android浏览器启动应用程序

use*_*175 5 android android-manifest android-intent

每当我在浏览器中输入"myapp://blah.com/a?b = 1&c = 2"时,我都需要浏览器启动我的应用程序.我在这个主题上搜索了很多,但没有答案真的帮助了我.你能帮忙理解我错过的东西吗?

<activity android:name=".MyAppMain"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation" 
              android:screenOrientation="portrait">
        <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>
    </activity>
Run Code Online (Sandbox Code Playgroud)

从Eclipse(Run As Android应用程序)安装后,我的应用程序可以自行运行,但是当我输入"myapp://blah.com/a?b = 1&c = 2"时,浏览器只是在搜索此字符串.你能指出我还缺少什么吗?我是否需要在安装后以某种方式在我想要处理"myapp://"urls的系统中注册?

Sam*_* Z. 0

我已经使用以下方法完成了此操作

  <activity android:name=".ReceiveInviteActivity">

            <intent-filter >
                <category android:name="android.intent.category.BROWSABLE" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                 <data
                 android:scheme="appname" 
                 android:host="project.example.com"

                />
            </intent-filter>

        </activity>
Run Code Online (Sandbox Code Playgroud)

和活动

 if (Intent.ACTION_VIEW.equals(action)) {
            final List<String> segments = intent.getData().getPathSegments();
            Log.d("LISTARRAY",segments.toString());
            String idString = segments.get(0);
            Log.d("LISTITEM",segments.get(0).getClass().toString());
            String friendId = idString.substring((idString.indexOf("="))+1);
            Log.d("friendId!",friendId);
Run Code Online (Sandbox Code Playgroud)

我希望这能帮到您。