开发者

Intent filter with vendor specific MIME type

开发者 https://www.devze.com 2023-01-08 17:17 出处:网络
The app AndroidVNC defines the following activity filter in its manifest: <activity android:screenOrientation=\"landscape\" android:configChanges=\"orientation|keyboardHidden\" android:name=\"VncC

The app AndroidVNC defines the following activity filter in its manifest:

        <activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:name="VncCanvasActivity">
           <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd开发者_C百科.android.cursor.item/vnd.vnc.config" />
           </intent-filter>
         </activity>

If it is possible to invoke this activity, you need a URI for the vendor specific MIME type vnd.vnc.config. Something to replace FOO in the following code is needed:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("FOO")); startActivity(intent);

So what string is needed for Uri.parse() to match a vendor specific MIME type like vnd.vnc.config? Given a vendor specific MIME type like vnd.vnc.config, in general how do you determine what string to pass into Uri.parse() to match such a MIME type?

===========================================

I've appended AndroidVNC's entire AndroidManifest.xml file at the bottom of this question. Can a completely separate Android app invoke any or all of the activities specified in this AndroidManifest.xml file? If so, what specific version of the following code would that separate app use to match and invoke each activity in the AndroidManifest.xml file? Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("FOO")); startActivity(intent);

    <provider android:name="Provider"
        android:authorities="android.androidVNC.Provider" />

            <activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:name="VncCanvasActivity">
                    <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.vnc.config" />
                    </intent-filter>
            </activity>

        <activity android:name=".gui.ListVncSettingsActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".gui.InsertVncSettingsActivity">
        <intent-filter>
            <action android:name="android.intent.action.INSERT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.dir/vnd.vnc.config" />
        </intent-filter>
    </activity>

    <activity android:name=".gui.EditVncSettingsActivity">
        <intent-filter>
            <action android:name="android.intent.action.EDIT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.vnc.config" />
        </intent-filter>
    </activity>
    <activity android:name=".gui.DeleteVncSettingsActivity">
        <intent-filter>
            <action android:name="android.intent.action.DELETE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.vnc.config" />
        </intent-filter>
    </activity>

    </application>




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


Something to replace FOO in the following code is needed:

Not necessarily. Call setType() on the Intent. Depending on how they implemented the activities, they may not even need FOO.

Given a vendor specific MIME type like vnd.vnc.config, in general how do you determine what string to pass into Uri.parse() to match such a MIME type?

You ask the authors of the activity. Perhaps they are expecting to be processing links where a Web server serves up that MIME type. Perhaps they have an associated ContentProvider that serves up content with that MIME type. Perhaps they have other approaches in mind. In this case, they have a <provider> element, which is a clue.

Can a completely separate Android app invoke any or all of the activities specified in this AndroidManifest.xml file?

It can certainly try. To determine what the activities expect, ask the authors of the activities, or read their source code. Particularly with respect to any Uri that the activities expect, you will not necessarily get enough information just by looking at the manifest. This is no different than a book: reading the table of contents is not the same as reading the book.

0

精彩评论

暂无评论...
验证码 换一张
取 消