1

I want to launch my own application when the web link in browser is clicked. I search a lot on internet,and the method of solving this question is similar. But mine does't work. There is no effect when i click the web link Is there some other things i don't notice? Can anyone tell me where my application is wrong?Thank you

Here is my program:

the link is: google

URLApp.java:

public class URLApp extends Activity {
/** Called when the activity is first created. */

public void OnCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    final Intent intent = getIntent();
    final Uri uri = intent.getData();

    Log.i("++++++++++++++++++++++", uri.getScheme().toString());
}
}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.receiver"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".URLApp"
        android:label="@string/app_name" 
        android:launchMode="singleTask">
        <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="http"></data>
            <data android:host="www.google.com"></data>
        </intent-filter>   
    </activity>
</application>
</manifest>

Edit: After i define my own URL scheme,the program works. My own web link is

<a href="myapp://test">click me!</a>
<data android:scheme="myapp"></data>

Why it does not work by using android:scheme="http" Does anyone have the same problem?

airzhao520
  • 11
  • 2

1 Answers1

0
<intent-filter><action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.YOUR-URL-HERE.com" android:scheme="http"></data>
</intent-filter>

Maybe you could remove the android:host tag to react on all urls.

See also: Android Respond To URL in Intent

Community
  • 1
  • 1
Thkru
  • 4,218
  • 2
  • 18
  • 37
  • Thanks,Thomas K.I removed the android:host tag, it still does not work.Are there some settings that i should set on device itself? – airzhao520 May 15 '12 at 09:54