• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

conver image URi to Integer

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic