没有通过Android中的浏览器安装Android App

时间:2015-10-22 07:18:33

标签: android

我开发了一个Android应用程序,当用户在浏览器中输入特定网址时,已经安装在设备中的应用程序必须打开。我在Androidmanifest文件中使用了以下代码但是应用程序没有打开,它只是打开website.Please告诉我在我的代码中需要进行哪些更正?

网址为:http://www.myurl.co.gdf

manifestfile.xml

<application
    android:icon="@drawable/logo"
    android:label="@string/app" >
    <activity
        android:name="com.app.Activity1"
        android:configChanges="orientation|keyboardHidden"
        android:label="@string/service"
        android:screenOrientation="portrait"
        android:theme="@style/aa_theme" >
                  <intent-filter android:label="@string/app" >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
           <intent-filter>
        <data
            android:host="www.myurl.co.gdf"
            android:pathPrefix="/"
            android:scheme="http" >
        </data>

        <action android:name="android.intent.action.VIEW" />

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

     <activity
        android:name="com.app.Activity2"
        android:configChanges="orientation|keyboardHidden"
        android:label="@string/activity_title"
        android:screenOrientation="portrait"
        android:theme="@style/aa_theme" />
    </application>

此处出现的第一个屏幕是Activity2(登录屏幕),登录时我将导航到Activity1(主屏幕)屏幕

1 个答案:

答案 0 :(得分:0)

您不需要pathPrefix,因为它看起来像您要处理所有类型的URL。我尝试了它,它适用于我:

   <data
        android:host="www.myurl.co.gdf"
        android:scheme="http" >
    </data>

我测试了它,通过电子邮件发送给自己的链接,然后尝试打开此链接,我得到了我的应用程序作为选项。 在测试之前也尝试这样做:设置 - &gt;应用 - &gt;从操作栏(重置应用程序首选项)。

我认为你需要通过点击此网址来测试:http://www.myurl.co.gdf来自任何其他应用,例如messenger或whatsapp或电子邮件,然后您应该看到可以打开此网址的应用列表,您的应用应该在除了浏览器之外的列表。

如果您将网址直接放在浏览器中,那么为什么要在您的应用中打开它。应用程序不会打开,因为当您将URL放在浏览器中时它不会创建Intent。浏览器只会打开网页。只有在使用某些数据和操作启动意图时,您才能选择应用程序。基本上是基于android的意图,确定哪些应用程序可以处理它,然后显示应用程序列表。