views:

232

answers:

2

I don't know why, but in Eclair, the default (non-fancy) gallery app changed its begaviour from the Cupcake version, and it broke one of my commercial applications :-(

Firstly, when long-pressing a gallery and choosing "Diashow", it does not publish an Intent to be picked up by any application that implements the Intent filter anymore. Instead, it will directly call "com.android.gallery/com.android.camera.ViewImage" with extras.

Question: is it still possible to intercept this intent and allow the user to choose my application to do the Diashow?

Secondly, the intent extras for the VIEW intent are messed up (in my build of 2.1 anyway): Instead of providing the BucketId of the picture in the Intent's queryparameter. But in 2.1, the BucketId is moved to the Intent's extras. Except; it is not passing the BUCKET_ID, but the unlocalized BUCKET_DISPLAY_NAME instead :-/

Question: how can I still get the unique BUCKET_ID from the intent, so that I do not have to work with a potentially non-unique BUCKET_DISPLAY_NAME?

Is there anybody out there who has come up with a working solution for these problems?

I thought the whole idea of Android Intents was to be able to integrate your applications with the base Android environment, but my build of 2.1 proves that this idea still lives in the land of Theory :-(

+1  A: 

Firstly, when long-pressing a gallery and choosing "Diashow", it does not publish an Intent to be picked up by any application that implements the Intent filter anymore.

That Intent probably was not part of the SDK, meaning you should not have been relying upon it in the first place. There are no Intents for the Gallery application that are part of the SDK, other than to the extent the Gallery supports common Intents (e.g., GET_CONTENT, PICK).

Question: is it still possible to intercept this intent and allow the user to choose my application to do the Diashow?

I sure hope not, because that would mean there is a serious security hole.

Question: how can I still get the unique BUCKET_ID from the intent, so that I do not have to work with a potentially non-unique BUCKET_DISPLAY_NAME?

This Intent is not documented. Please do not attempt to use it. Your application will break on some Android devices that do not ship the standard Gallery application. Your application will break in future versions of Android, as you have already experienced. Please stick to Intents that have been documented by the application's author.

I thought the whole idea of Android Intents was to be able to integrate your applications with the base Android environment

Only where those Intents were documented and are supported by the authors of the application in question. If you thought that you could just grab random Intents you found in the source code or in LogCat or something, and use those, you were mistaken.

CommonsWare
Thanks Commonsware!You have valid points there, but: I still do not understand why there should be a distinction between the published standard VIEW intent, which does allow 3rd party apps to handle a request to view a single picture, and a VIEW intent with a flag to indicate that a slideshow should be started.Secondly, bucket_id is part of the document media columns and I think it would be only decent to have that information in the standard VIEW intent so the 3rd party application knows a little bit more about the context that it was started in.
Schermvlieger
The distinction is that your flag is undocumented. If it is undocumented, it is unsupported and is subject to change, just as you discovered. http://www.androidguys.com/2009/12/14/code-pollution-reaching-past-the-sdk/
CommonsWare
A: 

Question: is it still possible to intercept this intent and allow the user to choose my application to do the Diashow?

Answer for your first question.... But with this, you might need to rebuild your app and then update...

To make it only your activity to receive the intent fired by you, add an additional flag to the intent or Create your own custom action and then fire an intent. On receiving activity, set an intent filter in your application manifest file mentioning about your custom action. You're done here. Only the activity assigned with your custom action Intent filter will receive your Intent.

Question: how can I still get the unique BUCKET_ID from the intent, so that I do not have to work with a potentially non-unique BUCKET_DISPLAY_NAME?

Do not attempt this as you might end up in trouble as it might break your app on previous android versions.

Vishwanath