Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent filter with scheme and host does not work

Tags:

android

I have a following intent filter:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="content" android:host="my.company.name" />
</intent-filter>

But it does not match the following Intent:

Uri uri = new Uri.Builder().scheme("content").authority("my.company.name").appendPath("names").build()
uri = Uri.withAppendedPath(uri, id1);
uri = Uri.withAppendedPath(uri, "data");

startActivity(new Intent(Intent.ACTION_VIEW, uri));

Why does this happen?

like image 323
Fixpoint Avatar asked Dec 01 '25 14:12

Fixpoint


1 Answers

It may be that you cannot register an activity for the content scheme, as that is used by the content provider system.

If your activity really is backed by content providers, use the MIME type for the content instead, such as:

<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />

If this relates to your other recent SO question, you may wish to follow the advice of the Google employee who answered that question. Here is a sample project demonstrating this technique, particularly the third <intent-filter> in the manifest.

like image 162
CommonsWare Avatar answered Dec 05 '25 06:12

CommonsWare