[squeak-dev] New CogDroid alpha: with intent filter.

Dimitry Golubovsky golubovsky at gmail.com
Sun Sep 18 04:54:39 UTC 2011


I have uploaded a new alpha of CogDroid:

http://squeakvm-tablet.googlecode.com/files/CogDroid-alpha-20110918.apk

Intent filtering has been added to the application. Also application
icon and Java package name (org.golubovsky.cogstack) have been
updated.

Intents in Android are messages that an application may pass around to
invoke other applications that subscribe to filtering intents with
some properties.

That is, another application may broadcast an Intent (via
startActivity()) with scheme "file", content-type
"application/x-squeak-image", and path to the image as data. CogDroid
will start right with the image given (provided that it exists)
without scanning the sdcard storage for available image files.

Sample Java code for this:

    public void launchImage(String imgpath) {
            Intent cog = new Intent();
            cog.setAction(Intent.ACTION_VIEW);
            Uri uri = new Uri.Builder().scheme("file").path(imgpath).build();
            cog.setDataAndType(uri, "application/x-squeak-image");
            try {
                    startActivity(cog);
            } catch (Exception e) {
                // process the exception: it is raised if no
recipients were found for this intent, e. g. CogDroid is not
installed.
            }
    }

Relevant section in CogDroid's AndroidManifest.xml:

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file"
                        android:mimeType="application/x-squeak-image" />
            </intent-filter>

I also created a simple launcher for two images (the application when
installed shows an icon for each image). Unfortunately image paths are
hardcoded (but just for illustration this should be OK), and a single
Activity subclass is required for each image file.

See under https://gitorious.org/~golubovsky/cogvm/dmg-blessed/trees/master/platforms/android/utils/imglaunch

Thanks.


-- 
Dimitry Golubovsky

Anywhere on the Web



More information about the Squeak-dev mailing list