-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading images from local storage for listview in appwidget may cause SecurityException #1405
Comments
Can you please run
to confirm what permissions you have. If you indeed doesn't have that permission, it's possible the app-widget callbacks are tripping you. As a workaround you can try to do this: public class App extends Application {
public void onCreate() {
super.onCreate();
Glide.with(this); // force initialization within your app's domain
}
} |
What is |
@TWiStErRob I followed your suggestion that writing |
The check for the permission may be wrong, and likely detects something that only happens in that service, because it is called by the system. @sjudd any idea why this could be? |
AppWidget sometimes had weird issues with permissions. See http://stackoverflow.com/a/20645908/691639 for a possible solution. |
I'm not sure, open to suggestions/pull requests. |
Actually I think this is an explanation for #1417, I'll call this a duplicate of that for now. |
I take it back, that only catches exceptions register the receiver, which is probably different. I need to catch more things here... |
I was able to fix the image loading issue for the RemoteViews within the widget by using Glide. This solution was largely taken from the following GitHub issue: bumptech/glide#1405
I'm using Glide 3.7.0 to load images from local storage to a
ListView
in an appwidget. Here's a part of my code:I didn't use
Glide.with(context).asBitmap().into(AppWidgetTarget)
because it's useless to load image forListView
in appwidget. Anyway, above code will be executed inRemoteViewsFactory#getViewAt(int position)
inside my customRemoteViewsService
. It can work well at most time, but sometimes I will get following error info with images not loaded:It seems that this exception is caused by checking network state without corresponding permission. I didn't request
ACCESS_NETWORK_STATUS
permission inAndroidManifest.xml
indeed, but my app really doesn't need this permission. In my user case, Glide will only be used to load images from local storage so I think it should not do such kind of operation like checking network state. Maybe it's designed for loading images from everywhere including Internet(OK, perhaps this is most important user case), but I think it should handle this mistake if it's not asked to load images from Internet, and then load images correctly.Thank you.
The text was updated successfully, but these errors were encountered: