How to set icon from image(image in gallery)
In my app I want to create icon from image. So after first run app will open gallery and user must choose an image. Then I will resize it and will save to app-folder. But how to can I set this 开发者_JAVA技巧png to icon?
result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
Here I must use icon from resource. Is another way to set icon from image?
Maybe something it:
int imgID = getResources().getIdentifier("/data/data/
com.blogspot.vsvydenko/app_thumbnails/fullBrowser.PNG", "drawable",
getPackageName());
But I always got imgID == 0 ((
Thank.
In the case of a larger image (larger than icon size), you typically want to use a ContentProvider with getBlob().
From the documentation:
If a query can return binary data, such as an image or sound, the data may be directly entered in the table or the table entry for that data may be a string specifying a content: URI that you can use to get the data. In general, smaller amounts of data (say, from 20 to 50K or less) are most often directly entered in the table and can be read by calling Cursor.getBlob()
I suggest you read through the provided docs for ContentProvider. This may solve your problem.
As for resizing the image, for displaying, resizing, and storing images in Android, I suggest you check out the 2D graphics tutorial. It may help you understand what you need to do to perform this task correctly.
Hope this helped!
精彩评论