Android 2.1 图库无法向后兼容 Cupcake 版本,现在怎么办?
我不知道为什么,但在 Eclair 中,默认的(非花哨的)画廊应用程序从 Cupcake 版本更改了它的 begaviour,并且它破坏了我的一个商业应用程序:-(
首先,当长按画廊并选择“ Diashow”,它不再发布一个 Intent 供任何实现 Intent 过滤器的应用程序拾取。相反,它将直接调用带有额外功能的“com.android.gallery/com.android.camera.ViewImage”。
问题:是仍然可以拦截此意图并允许用户选择我的应用程序来执行 Diashow?
其次,VIEW 意图的意图附加内容被搞乱了(无论如何在我的 2.1 版本中):而不是提供图片的 BucketId但在 2.1 中,BucketId 被移至 Intent 的 extra;但它没有传递 BUCKET_ID
,而是传递未本地化的 BUCKET_DISPLAY_NAME
:-/
问题:我怎样才能从 Intent 中获取唯一的 BUCKET_ID
,这样我就不必使用可能不唯一的 BUCKET_DISPLAY_NAME
?
有没有人为这些问题提出可行的解决方案?
我认为 Android Intents 的整体理念是能够将您的应用程序与基础 Android 环境集成,但我的 2.1 构建证明这个想法仍然存在于理论领域:-(
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 :-(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该 Intent 可能不是 SDK 的一部分,这意味着您一开始就不应该依赖它。除了 Gallery 支持常见的
Intents
(例如GET_CONTENT
)之外,Gallery 应用程序没有属于 SDK 的任何Intents
,选择
)。我当然希望不会,因为这意味着存在严重的安全漏洞。
此
意图
没有记录。请不要尝试使用它。您的应用程序将在某些未附带标准图库应用程序的 Android 设备上崩溃。正如您已经经历过的那样,您的应用程序将在未来版本的 Android 中崩溃。请遵循应用程序作者记录的Intents
。仅当这些
Intents
被记录并得到相关应用程序作者的支持时。如果您认为可以获取在源代码或 LogCat 等中找到的随机Intents
并使用它们,那么您就错了。That
Intent
probably was not part of the SDK, meaning you should not have been relying upon it in the first place. There are noIntents
for the Gallery application that are part of the SDK, other than to the extent the Gallery supports commonIntents
(e.g.,GET_CONTENT
,PICK
).I sure hope not, because that would mean there is a serious security hole.
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 toIntents
that have been documented by the application's author.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 randomIntents
you found in the source code or in LogCat or something, and use those, you were mistaken.回答你的第一个问题......但是这样,你可能需要重建你的应用程序,然后更新......
为了使其只有你的活动接收你激发的意图,请向意图添加一个额外的标志或创建你的自己的自定义操作,然后触发一个意图。
接收活动时,在应用程序清单文件中设置一个意图过滤器,提及您的自定义操作。你已经完成了。只有分配有您的自定义操作意图过滤器的活动才会收到您的意图。
不要尝试这样做,因为您可能会遇到麻烦,因为它可能会破坏您在以前的 Android 版本上的应用程序。
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.
Do not attempt this as you might end up in trouble as it might break your app on previous android versions.