获取其他应用程序图标 uri?
我有一个 Android appwidget,它显示其他应用程序的图标。
我使用 appInfo.loadIcon 获取其他应用程序图标,然后使用 setImageViewBitmap 将其设置为小部件。
问题是,如果小部件上有太多图标,我会收到“FAILED BINDER TRANSACTION”错误。我知道这是由于大小限制以及使用图像 uri 而不是位图本身的解决方案。
是否有其他应用程序图标的可访问 URI?
谢谢。
I have an Android appwidget which shows icons of other applications on it.
I get the other applications icons with appInfo.loadIcon and then I set it to the widgets with setImageViewBitmap.
The problem is that if I have too many icons on the widget, I get "FAILED BINDER TRANSACTION" error. I understand that it's from a size limit and the solution it to use the image uri instead of the bitmap itself.
Is there an accessible URI to other applications' icons?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您不知道资源名称,也可以通过资源 ID 来访问资源:
应用图标的资源 ID 可在应用的
ApplicationInfo
中找到:In case you don't know the resource name, you can also access resources by their id:
The resource id of the app icon is available in the
ApplicationInfo
of the app:虽然 @CommonWare 的答案在很多情况下都很好,但我发现这通常更容易:
android.resource://[package]/[res id]
- 特别是当您想要引用其他应用程序的启动器图标时。While @CommonWare's answer is good in many cases, I find that this is often easier:
android.resource://[package]/[res id]
- especially when you want a reference to for instance the launcher icon of some other app.尝试
android.resource://[package]/[res type]/[res name]
,其中[res type]
在您的情况下将是drawable< /代码>。包和名称必须来自
ResolveInfo
或您获取数据的任何位置。Try
android.resource://[package]/[res type]/[res name]
, where[res type]
in your case would bedrawable
. The package and name would have to come from theResolveInfo
or wherever you are getting your data.