wn URI に基づいて、単純なカスタム インテントを受信しようとしています。
これが私のマニフェストです:
<uses-sdk
android:minSdkVersion="14"
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.example.intenttest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.example.intenttest.TestReceive"
android:enabled="true"
android:exported="true" >
<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="testo" />
</intent-filter>
</receiver>
</application>
私の受信機は非常に単純です。
public class TestReceive extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
Log.d("", "YAY!!!!!");
Toast.makeText(context, "TEST!!!", Toast.LENGTH_LONG).show();
}
}
testo://blahblah をブラウジングしようとしたり、URI Launer を介してこのインテントを実行しようとすると、レシーバーが起動されません。
別のアプリからのインテントの起動をシミュレートするコードを次に示します。
String url = "testo://test/test";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
sendBroadcast( i );
しかし、<intent-filer>
ブロックを<activity>
マニフェストのタグに移動すると、アクティビティが発生します。
受信者にインテントを受信させるにはどうすればよいですか?