I made an image viewer that has 3 activities:

1) Main: where I search for files using regexp against filenames. The result is an ArrayList called 'files' that is sent using Extras to...

2) Thumbs: Through Extras it gets the filenames, and shows a grid with thumbnails (already stored locally). When you click a thumbnail, the position and 'files' is sent to...

3) Photo: It shows files(position) fullscreen.

Now, I want to make 'Photo' my default image viewer. I know how to call the class from another app. But is is possible to make 'Photo' the default viewer just by clicking an image, without calling the whole app?

有帮助吗?

解决方案

In your manifest under your "Photo" image viewer activity add the following intent filter:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>

You'll need to get the URI of the image from within the intent to display it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top