How to setImageViewUri in Widget using getFileStreamPath()?

by Matt M » Sun, 13 Mar 2011 02:44:23 GMT


Sponsored Links
 Hello,

This is really baffling. In an AppWidgetProvider I am trying to
setImageViewUri using this Uri: Uri.fromFile(getFileStreamPath(name))

I know the file exists in internal storage because I've tried
File.exists(), and I also successfully tried:

Bitmap b =
BitmapFactory.decodeFile(getFileStreamPath(path).getAbsolutePath());
views.setImageViewBitmap(id, b);

I need to do this with 3 images of varying size so converting to a
Bitmap is out of the question (I get a Failed Binder Transaction
regularly).

Why is it that I can use the same getFileStreamPath to create a bitmap
but cannot create the Uri to use in setImageViewUri? (this is all in
an AppWidgetProvider)

Any help would be greatly appreciated!

Matt.

-- 



Re: How to setImageViewUri in Widget using getFileStreamPath()?

by Kostya Vasilyev » Sun, 13 Mar 2011 03:00:35 GMT


 Matt,

I'm assuming your widget is running inside the home screen application 
(Launcher2 by default).


The launcher is a separate application from your own, and therefore 
cannot access files stored in your application's private data storage 
directory.


Create these image files someplace where other applications (including 
the launcher) can read them.


-- Kostya

12.03.2011 21:44, Matt M :
Hello, This is really baffling. In an AppWidgetProvider I am trying to setImageViewUri using this Uri: Uri.fromFile(getFileStreamPath(name)) I know the file exists in internal storage because I've tried File.exists(), and I also successfully tried: Bitmap b = BitmapFactory.decodeFile(getFileStreamPath(path).getAbsolutePath()); views.setImageViewBitmap(id, b); I need to do this with 3 images of varying size so converting to a Bitmap is out of the question (I get a Failed Binder Transaction regularly). Why is it that I can use the same getFileStreamPath to create a bitmap but cannot create the Uri to use in setImageViewUri? (this is all in an AppWidgetProvider) Any help would be greatly appreciated! Matt.
-- Kostya Vasilyev -- http://kmansoft.wordpress.com --


Sponsored Links


Re: How to setImageViewUri in Widget using getFileStreamPath()?

by Matt M » Sun, 13 Mar 2011 03:11:59 GMT


 Thank you for your replay Kostya.

The solution I chose was to change the privacy during saving. Changed
openFileOutput(file, Context.MODE_PRIVATE) to openFileOutput(file,
Context.MODE_WORLD_READABLE)

Thank you.

Matt.




-- 



Other Threads

1. .apk install fails: package conflict

I'm testing an app I'm developing and asked a friend to install on
their device. I wanted to make it as easy as possible for them to help
me out so I put the .apk up on my website for them to download to the
phone (rather than making them download the SDK and use adb to
install). The install of the downloaded .apk fails, complaining of a
package conflict.

I have since gotten my hands on the phone briefly and I verified that:
* they have selected "allow unsigned apps" in settings
* there is no package with the same (or similar) name in data/data
* installing via adb works with not a peep
* when I download the .apk to my phone the app installs fine

Any ideas what's up? It would be really nice to make it as easy as
possible to distribute to people who might be willing to do me the
favor of testing.

Thanks for any help,
Bee

--~--~---------~--~----~------------~-------~--~----~

2. Freedom cuts both ways (Cupcake coming in April? Where is the SDK?)

ah Sundog Sdk release might be late April..









--~--~---------~--~----~------------~-------~--~----~

3. Receiving SMS Messages in 1.0?

4. All SYMBIAN based end devices accept Java language Applications :: Need Clarifications

5. All SYMBIAN based end devices accept Java language Applications :: Need Clarifications

6. Process is not ending ?

7. how can i check landscap orientation ?