2

i know my question is been asked for many times here but i tried all the answers and still have the problem my problem is that i want my application to be opened throw url from the mobile browser

here is what i write in the mainfeast.xml file

       <activity
        android:name=".Login"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <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="" android:scheme="mpay2park" />
        </intent-filter>

and still can't solve this issue what I want to know that if I should write anything in the Login.java activity or not and what is the URLthat I should to write for this

Thank you

Basant
  • 305
  • 1
  • 8
  • 23
  • "and still can't solve this issue" -- and the issue is, what, precisely? If the issue you failed to write is that your activity is not a choice for `mpay2park://` URLs, I would delete `android:host=""`. – CommonsWare Aug 30 '12 at 23:58
  • the issue that the url didn't open my app – Basant Aug 31 '12 at 00:04
  • Then delete `android:host=""` and try again. If it still does not work, show a sample URL that is failing. – CommonsWare Aug 31 '12 at 00:08
  • i write in the browser mpay2park:// and didn't work :( – Basant Aug 31 '12 at 00:11
  • @CommonsWare could you have a look a this question http://stackoverflow.com/questions/12175259/custom-mediaplayer-class-in-android. Sorry Basant, I dont know any other way to communicate with CommonWare. – Lazy Ninja Aug 31 '12 at 01:07
  • Basant, did you try deleting android:host="" as CommonsWare said? – Stephan Branczyk Aug 31 '12 at 01:16
  • @ Stephan yes i delete android:host and nothing is hapened ,andi want to ask if there any code should i write in activity java file..thank you – Basant Aug 31 '12 at 07:09

2 Answers2

2

You can use below manifest file to open abc://xyz.com from browser addressbar :

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.sample.openfrombrowser.MainActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:launchMode="singleInstance" >
        <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:host="xyz.com"
                android:scheme="abc" />
        </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:host="google.co.in"
                android:pathPrefix="/"
                android:scheme="http" />
            <data
                android:host="www.google.co.in"
                android:pathPrefix="/"
                android:scheme="http" />
        </intent-filter>
    </activity>
</application>

This will ask option(with your application name) in dialog to open this url.

hope so this will work for you.

Enjoy.

Nirav Shah
  • 2,064
  • 5
  • 24
  • 34
1

I solve my problem ,here is what i write on mainfest file

  <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="mpay2park"/>
        </intent-filter>

and I change the android browser and open my like from opera mini and it works perfect for me

Basant
  • 305
  • 1
  • 8
  • 23