• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

conver image URi to Integer

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application ,there is a image array.

Integer[] images = new Integer[global.getID().length];

I have a URi of a Photo.I need that URi to add to that image array.How to convert image URI to INTEGER ?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A URI has much more information than fits into an integer. What is the underlying problem you're trying to solve?
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my application i have contatct numbers(Phone numbers ex :0717675453);

So i need to get photo related to each numbers.Then i am going to add them to INTEGER array.So i have phone numbers ,images as arays.Then in a loop i add them to a contact objects.
So i have a method which returns a photo as a URI when i gave a contact no(0712345643).I need to add a URI to INTERGER array.
 
Maneesh Godbole
Saloon Keeper
Posts: 11325
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Map will be a better structure for what you are trying to do.
The phone number can be the key and the image URI the value
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i used Integer array for images,if i don't find a photo i give default image from drawable folder.So drawable images are represent as integers.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sameera liyanage wrote:actually i used Integer array for images,if i don't find a photo i give default image from drawable folder.So drawable images are represent as integers.

So the integer you want is specifically a Resource ID found in the R.drawable class (because that is how the integer you use for the default image would be used). Those IDs are created at compile time, so you can not do what you want. You need a different way of specifying the image.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i have image URI now.can you tell me How to show them in my app?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked into the API? What view are you using to show the image? An ImageView has a pretty obvious method to use. On the other hand, you probably want to download the image and store it in the app's data folder, then display it from there (so the user doesn't have to be connected to the internet to show the image). So you will probably want a background task to do the downloading for you. You would then use a Bitmap to load the image from disk, and display the loaded Bitmap.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic