ParcelFileDescriptor and Service problem

Put your problem here if it does not fit any of the other categories.

ParcelFileDescriptor and Service problem

Postby spinwin » Tue Jun 08, 2010 5:59 am

I try to do the following :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ParcelFileDescriptor fdMonster = remoteService.getMonster().getImage();
  2. Bitmap bmpMonster1 = BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor());
  3.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


RemoteService is a service defined by me whith AIDL and Parcelable object named "Monster".

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. AssetFileDescriptor afd = getResources().openRawResourceFd(R.drawable.l);
  2. ParcelFileDescriptor pfd = afd.getParcelFileDescriptor();
  3. monster.setImage(pfd);
  4.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The problem is that "fdMonster" seems to load (object not empty) but when I do "BitmapFactory.decodeFileDescriptor' I get a null bitmap :!: I do not understand :!: Does anyone have an idea about my problem please :?:
spinwin
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jun 08, 2010 5:45 am

Top

Re: ParcelFileDescriptor and Service problem

Postby RandyJames » Sat Jan 22, 2011 3:30 am

You ever figure this out? I'm having the same issue.
Found a number of people with it as well.

I'm trying to load images from a content provider (that I created) as well.
This works just fine (rather, no exceptions are thrown and the FileDescriptor claims it is valid)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(Uri.parse(imageURI), "r");
  2. if (pfd.getFileDescriptor().valid())
  3.      Log.d("MoveActivity", "File descriptor is valid!");
  4.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


But when I try to decode it into a bitmap, like you said, I get null.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Options options = new Options();
  2. options.inJustDecodeBounds = true;
  3. Bitmap bm = BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(),null,options);
  4. if (bm == null)
  5.         Log.d("MoveActivity", "TURDS.  Bitmap is null");
  6.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


I've tried it the above way and your more simple way...
This must have something to do with the fact that the filedescriptor is coming from the content provider....
RandyJames
Once Poster
Once Poster
 
Posts: 1
Joined: Mon May 24, 2010 3:10 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Adsense [Bot], Yahoo [Bot] and 18 guests