0

I have developed an Android app,When user enters particular url in browser the app which has been installed in device has to get opened.i have used below code in Androidmanifest file but app is not getting opened ,it is only opening in website.Please tell me what corrections have to make in my code?

url is :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>

Here first screen that appears is Activity2(login screen) ,on login i will be navigated to Activity1(Home screen) screen

allDroid
  • 405
  • 1
  • 10
  • 21

1 Answers1

0

You don't need a pathPrefix since it looks like you want to handle all the urls of type. I tried it and it works for me:

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

I tested it my emailing the link to myself and then try to open this link and I got my app as an option. Try doing this also before you test it out: Settings -> Apps -> from the action bar(Reset App Preferences).

I think you need to test by clicking on this url :http://www.myurl.co.gdf from any other app like messenger or whatsapp or email and then you should see a list of apps which can open this url and your app should be in the list apart from browsers.

If you put the url directly in the browser then why should it open in your app. The app will not get opened because it is not creating a Intent when you put the url in a browser. Browser will just open the webpage. You get an option to select the app only when you start an intent with some data and action. Basically based on the intent android figures out which apps can handle it and then show you a list of apps.

pgiitu
  • 1,671
  • 1
  • 15
  • 23
  • if i put url in browser ,app has to get opened but why its not working? – allDroid Oct 22 '15 at 07:46
  • The app will not get opened because it is not creating a Intent when you put the url in a browser. Browser will just open the webpage. You get an option to select the app only when you start an intent with some data and action. Basically based on the intent android figures out which apps can handle it and then show you a list of apps. Did you try opening the url from a messenger type app? – pgiitu Oct 22 '15 at 07:50
  • even in whatsapp its(app) not appearing in list – allDroid Oct 22 '15 at 09:07
  • please tell me what else should i add to this.OR should i use custom schema or anything else – allDroid Oct 22 '15 at 10:22
  • this is implemented in ios its working fine in that, that developer has to add :// to url then app installed in device get opened when user enters url in browser in ios ,like this while i enter url in android should i add anything else extra to url to make app open currently i will enter www.myurl.co.gdf or http://www.myurl.co.gdf in browser is this right way . – allDroid Oct 23 '15 at 13:51
  • two more thing i have to inform you about my observation is that if these is added in manifestfile as above, in my app login screen there is this url hyperlink its for the user to open this website ,when i click choose dialog box appears with list of internet,chrome and opera(my app is not included in this, this is not required and i am not even aiming to do this but i get this after adding this code) – allDroid Oct 23 '15 at 13:52
  • @ pgiitu and 2nd observtn is that when url enter in browser website get opens in browser itself ,in that there is ui to "registration","not a member" and "member" when i click on these things choose dialog box appears with list of my app other browsers. – allDroid Oct 23 '15 at 13:53