Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9492 > unrolled thread

Android URI to drawable

Started byDirk Bruere at NeoPax <dirk.bruere@gmail.com>
First post2011-11-04 01:33 +0000
Last post2011-11-03 21:59 -0700
Articles 7 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Android URI to drawable Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-11-04 01:33 +0000
    Re: Android URI to drawable Lew <lewbloch@gmail.com> - 2011-11-03 19:15 -0700
      Re: Android URI to drawable Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-11-04 02:41 +0000
        Re: Android URI to drawable Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-11-04 03:38 +0000
          Re: Android URI to drawable Lew <lewbloch@gmail.com> - 2011-11-04 08:54 -0700
            Re: Android URI to drawable Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-11-06 00:06 +0000
    Re: Android URI to drawable Roedy Green <see_website@mindprod.com.invalid> - 2011-11-03 21:59 -0700

#9492 — Android URI to drawable

FromDirk Bruere at NeoPax <dirk.bruere@gmail.com>
Date2011-11-04 01:33 +0000
SubjectAndroid URI to drawable
Message-ID<9hgtnoF760U1@mid.individual.net>
Drawable d = 
Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7 
Ashbourne Radio.jpg");

This returns null, even though the path is correct.
Any ideas on how to do it?

-- 
Dirk

The New Futurism : ZERO STATE : http://zerostate.net

[toc] | [next] | [standalone]


#9497

FromLew <lewbloch@gmail.com>
Date2011-11-03 19:15 -0700
Message-ID<7367201.498.1320372924453.JavaMail.geo-discussion-forums@prep8>
In reply to#9492
Dirk Bruere at NeoPax wrote:
> Drawable d = 
> Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7 
> Ashbourne Radio.jpg");
> 
> This returns null, even though the path is correct.
> Any ideas on how to do it?

Here is a lesson in why you should put all the necessary information in the body of your post, and not just in the subject.  Your subject refers to "Android URI", but the body of your post talks about a Windows path.  That is confusing.

Regardless, the evidence from the tiny bit of information you provide is that the path is most definitely *not* correct.  At the very least, you should re-examine that assumption and take steps to prove it.  (E.g., write a unit test that test for something like 'new File("your path").exists()'.)  Don't assume the path is right, prove that it's right.  I will bet you fifty bucks that it isn't.  (Monopoly money only.)

Please give ocmplete information in your post.  Is this a Windows problem or an Android problem?  If this is Android, then the path isn't even correctly formatted, much less correct.

You should consider using 'System.getProperty("file.separator")' or equivalent instead of hard-coding non-portable idioms.

Also, I see no evidence of a URI in your code snippet.  How does that figure in?

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#9500

FromDirk Bruere at NeoPax <dirk.bruere@gmail.com>
Date2011-11-04 02:41 +0000
Message-ID<9hh1nbF1ugU1@mid.individual.net>
In reply to#9497
On 04/11/2011 02:15, Lew wrote:
> Dirk Bruere at NeoPax wrote:
>> Drawable d =
>> Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7
>> Ashbourne Radio.jpg");
>>
>> This returns null, even though the path is correct.
>> Any ideas on how to do it?
>
> Here is a lesson in why you should put all the necessary information in the body of your post, and not just in the subject.  Your subject refers to "Android URI", but the body of your post talks about a Windows path.  That is confusing.
>
> Regardless, the evidence from the tiny bit of information you provide is that the path is most definitely *not* correct.  At the very least, you should re-examine that assumption and take steps to prove it.  (E.g., write a unit test that test for something like 'new File("your path").exists()'.)  Don't assume the path is right, prove that it's right.  I will bet you fifty bucks that it isn't.  (Monopoly money only.)
>
> Please give ocmplete information in your post.  Is this a Windows problem or an Android problem?  If this is Android, then the path isn't even correctly formatted, much less correct.
>
> You should consider using 'System.getProperty("file.separator")' or equivalent instead of hard-coding non-portable idioms.
>
> Also, I see no evidence of a URI in your code snippet.  How does that figure in?
>

Thanks.
In replying to this I think I have just realized what is wrong.
How to fix it is another matter

-- 
Dirk

The New Futurism : ZERO STATE : http://zerostate.net

[toc] | [prev] | [next] | [standalone]


#9501

FromDirk Bruere at NeoPax <dirk.bruere@gmail.com>
Date2011-11-04 03:38 +0000
Message-ID<9hh51sFndkU1@mid.individual.net>
In reply to#9500
On 04/11/2011 02:41, Dirk Bruere at NeoPax wrote:
> On 04/11/2011 02:15, Lew wrote:
>> Dirk Bruere at NeoPax wrote:
>>> Drawable d =
>>> Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7
>>> Ashbourne Radio.jpg");
>>>
>>> This returns null, even though the path is correct.
>>> Any ideas on how to do it?
>>
>> Here is a lesson in why you should put all the necessary information
>> in the body of your post, and not just in the subject. Your subject
>> refers to "Android URI", but the body of your post talks about a
>> Windows path. That is confusing.
>>
>> Regardless, the evidence from the tiny bit of information you provide
>> is that the path is most definitely *not* correct. At the very least,
>> you should re-examine that assumption and take steps to prove it.
>> (E.g., write a unit test that test for something like 'new File("your
>> path").exists()'.) Don't assume the path is right, prove that it's
>> right. I will bet you fifty bucks that it isn't. (Monopoly money only.)
>>
>> Please give ocmplete information in your post. Is this a Windows
>> problem or an Android problem? If this is Android, then the path isn't
>> even correctly formatted, much less correct.
>>
>> You should consider using 'System.getProperty("file.separator")' or
>> equivalent instead of hard-coding non-portable idioms.
>>
>> Also, I see no evidence of a URI in your code snippet. How does that
>> figure in?
>>
>
> Thanks.
> In replying to this I think I have just realized what is wrong.
> How to fix it is another matter
>

What I need is a path I can use.
The machine I am looking for is on the LAN, and named "Base".
The path on that machine is e:\\Config\\$NetRadioCovers\\Other\\96.7
Ashbourne Radio.jpg"

What is the correct path string with the machine name added?

-- 
Dirk

The New Futurism : ZERO STATE : http://zerostate.net

[toc] | [prev] | [next] | [standalone]


#9517

FromLew <lewbloch@gmail.com>
Date2011-11-04 08:54 -0700
Message-ID<975530.124.1320422077528.JavaMail.geo-discussion-forums@yqbl36>
In reply to#9501
Dirk Bruere at NeoPax wrote:
> Dirk Bruere at NeoPax wrote:
>> Lew wrote:
>>> Dirk Bruere at NeoPax wrote:
>>>> Drawable d =
>>>> Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7
>>>> Ashbourne Radio.jpg");
>>>>
>>>> This returns null, even though the path is correct.
>>>> Any ideas on how to do it?
>>>
>>> Here is a lesson in why you should put all the necessary information
>>> in the body of your post, and not just in the subject. Your subject
>>> refers to "Android URI", but the body of your post talks about a
>>> Windows path. That is confusing.
>>>
>>> Regardless, the evidence from the tiny bit of information you provide
>>> is that the path is most definitely *not* correct. At the very least,
>>> you should re-examine that assumption and take steps to prove it.
>>> (E.g., write a unit test that test for something like 'new File("your
>>> path").exists()'.) Don't assume the path is right, prove that it's
>>> right. I will bet you fifty bucks that it isn't. (Monopoly money only.)
>>>
>>> Please give ocmplete information in your post. Is this a Windows
>>> problem or an Android problem? If this is Android, then the path isn't
>>> even correctly formatted, much less correct.
>>>
>>> You should consider using 'System.getProperty("file.separator")' or
>>> equivalent instead of hard-coding non-portable idioms.
>>>
>>> Also, I see no evidence of a URI in your code snippet. How does that
>>> figure in?
>>>
>>
>> Thanks.
>> In replying to this I think I have just realized what is wrong.

And that would be what, exactly?  (With emphasis on the "exactly".)

>> How to fix it is another matter
>>
> 
> What I need is a path I can use.
> The machine I am looking for is on the LAN, and named "Base".
> The path on that machine is e:\\Config\\$NetRadioCovers\\Other\\96.7
> Ashbourne Radio.jpg"
> 
> What is the correct path string with the machine name added?

You need a LAN-aware or WAN-aware file system.

Your subject line has the right idea - refer to the resource via a URI, specifically a URL.

URLs are made available by drivers or servers that recognize the access protocol.  For example. to read a local file or one that is presented as such by your network driver, you can use the "file://" protocol.  The file system understands that one.  On the Web you use the "http://" protocol.  Web servers understand that one.

There is no automatic network driver that presents files on the host as files on the Android device.  If you do mount one, it will present the remote files in Android (i.e., Linux) file-system syntax, not Windows.  This is true for any remote-file access system - the resource presented as a file is in terms of the local file system, not the remote one.  That's basic networking.

So make a server (file system, Web, FTP, or whatever) that presents the desired resource via a URL, then connect to it in the appropriate way (network, HTTP client, FTP client, ...) from the Android device, using a 'java.net.URL' to get to it.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#9629

FromDirk Bruere at NeoPax <dirk.bruere@gmail.com>
Date2011-11-06 00:06 +0000
Message-ID<9hm1clF3lfU1@mid.individual.net>
In reply to#9517
On 04/11/2011 15:54, Lew wrote:
> Dirk Bruere at NeoPax wrote:
>> Dirk Bruere at NeoPax wrote:
>>> Lew wrote:
>>>> Dirk Bruere at NeoPax wrote:
>>>>> Drawable d =
>>>>> Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7
>>>>> Ashbourne Radio.jpg");
>>>>>
>>>>> This returns null, even though the path is correct.
>>>>> Any ideas on how to do it?
>>>>
>>>> Here is a lesson in why you should put all the necessary information
>>>> in the body of your post, and not just in the subject. Your subject
>>>> refers to "Android URI", but the body of your post talks about a
>>>> Windows path. That is confusing.
>>>>
>>>> Regardless, the evidence from the tiny bit of information you provide
>>>> is that the path is most definitely *not* correct. At the very least,
>>>> you should re-examine that assumption and take steps to prove it.
>>>> (E.g., write a unit test that test for something like 'new File("your
>>>> path").exists()'.) Don't assume the path is right, prove that it's
>>>> right. I will bet you fifty bucks that it isn't. (Monopoly money only.)
>>>>
>>>> Please give ocmplete information in your post. Is this a Windows
>>>> problem or an Android problem? If this is Android, then the path isn't
>>>> even correctly formatted, much less correct.
>>>>
>>>> You should consider using 'System.getProperty("file.separator")' or
>>>> equivalent instead of hard-coding non-portable idioms.
>>>>
>>>> Also, I see no evidence of a URI in your code snippet. How does that
>>>> figure in?
>>>>
>>>
>>> Thanks.
>>> In replying to this I think I have just realized what is wrong.
>
> And that would be what, exactly?  (With emphasis on the "exactly".)
>
>>> How to fix it is another matter
>>>
>>
>> What I need is a path I can use.
>> The machine I am looking for is on the LAN, and named "Base".
>> The path on that machine is e:\\Config\\$NetRadioCovers\\Other\\96.7
>> Ashbourne Radio.jpg"
>>
>> What is the correct path string with the machine name added?
>
> You need a LAN-aware or WAN-aware file system.
>
> Your subject line has the right idea - refer to the resource via a URI, specifically a URL.
>
> URLs are made available by drivers or servers that recognize the access protocol.  For example. to read a local file or one that is presented as such by your network driver, you can use the "file://" protocol.  The file system understands that one.  On the Web you use the "http://" protocol.  Web servers understand that one.
>
> There is no automatic network driver that presents files on the host as files on the Android device.  If you do mount one, it will present the remote files in Android (i.e., Linux) file-system syntax, not Windows.  This is true for any remote-file access system - the resource presented as a file is in terms of the local file system, not the remote one.  That's basic networking.
>
> So make a server (file system, Web, FTP, or whatever) that presents the desired resource via a URL, then connect to it in the appropriate way (network, HTTP client, FTP client, ...) from the Android device, using a 'java.net.URL' to get to it.
>

Thanks.
The real fun started later, when the code I had began to work.
Seems there was an automatic s/w update on the prog I was trying to 
interface with the Android app. The new version of the s/w presented a 
correct URL to me.

-- 
Dirk

The New Futurism : ZERO STATE : http://zerostate.net

[toc] | [prev] | [next] | [standalone]


#9503

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-11-03 21:59 -0700
Message-ID<95s6b7d5ar44coquij87e4gue3ncr42237@4ax.com>
In reply to#9492
On Fri, 04 Nov 2011 01:33:52 +0000, Dirk Bruere at NeoPax
<dirk.bruere@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>Drawable d = 
>Drawable.createFromPath("e:\\Config\\$NetRadioCovers\\Other\\96.7 
>Ashbourne Radio.jpg");
>
>This returns null, even though the path is correct.
>Any ideas on how to do it?

I am not familiar with the Android API, but I would try reading the
JPG in several utilities to see if any complain it is not quite
kosher.  Load/Save sometimes cleans out weirdnesses.
Try converting to png.  If it works, I am correct.

JPG is an old format and more abused.


-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and 
faster each year, but the focus on money makes software manufacturers 
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore 
ignored. The manufacturer focuses on cheap gimicks like dancing paper 
clips to dazzle naive first-time buyers. The needs of existing 
experienced users are almost irrelevant. I see software rental as the 
best remedy.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web