ブラウザの Web リンクがクリックされたときに、独自のアプリケーションを起動したいと考えています。私はインターネットでよく検索しますが、この質問を解決する方法は似ています。しかし、私のものは機能しません。Web リンクをクリックしても効果がない 他に気づいていないことはありますか? 私のアプリケーションが間違っている場所を誰か教えてもらえますか?ありがとう
これが私のプログラムです:
リンクは:グーグル
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>
編集: 独自の URL スキームを定義すると、プログラムが動作します。私自身のウェブリンクは
<a href="myapp://test">click me!</a>
<data android:scheme="myapp"></data>
android:scheme="http" を使用しても機能しないのはなぜですか? 同じ問題を抱えている人はいますか?