The exception is:
04-01 14:09:30.274: ERROR/AndroidRuntime(719):
java.lang.RuntimeException: Failure delivering result ResultInfo
{who=null, request=1, result=-1, data=Intent { data=content://media/
external/images/media/7 }} to activity {com.app.name/
com.app.name.activity}:
android.database.CursorIndexOutOfBoundsException: Index -1 requested,
with a size of 1
What does that mean?
On Apr 1, 9:44 am, Streets Of Boston <[email protected]> wrote:
> I can't tell.
>
> Debug your code and see which statement throws an exception and see
> what exception is thrown and note the values of the variables (are
> some set to null when they shouldn't, for example).
>
> On Apr 1, 9:35 am, Bobbie <[email protected]> wrote:
>
> > I tried this code, and every time it force closes. The Uri object
> > gives me the Uri, but I can't see why it's failing... Please help!!!
>
> > Uri photoUri = intent.getData();
> > Cursor cursor = getContentResolver().query(photoUri, new String[]
> > {MediaStore.Images.ImageColumns.DATA}, null, null, null);
> > String absoluteFilePath = cursor.getString(0);
>
> > On Mar 26, 8:57 am, beachy <[email protected]> wrote:
>
> > > cheers, did not know that about Drawables will use Bitmaps then.
>
> > > Thanks,
> > > Greg.
>
> > > On Mar 25, 3:23 pm, Streets Of Boston <[email protected]> wrote:
>
> > > > This Uri is the logical (not physical) path used by theimagecontent
> > > > provider.
> > > > If you want to get the physical path to the actual file on the SD-
> > > > card, query this Uri:
>
> > > > Cursor cursor = query(photoUri, new String[]
> > > > {MediaStore.Images.ImageColumns.DATA}, null, null, null);
> > > > String absoluteFilePath = cursor.getString(0);
>
> > > > Now, absoluteFilePath is the physical path to yourimage, which you
> > > > can use in Drawable.createFromPath
>
> > > > Question: Why don't you create a Bitmap instead?
>
> > > > ...
> > > > InputStream is = getContentResolver().openInputStream(photoUri);
> > > > Bitmap bm = BitmapFactory.decodeStream(is);
> > > > ...
> > > > is.close();
>
> > > > I ask this, because it is safer to cache Bitmaps instead of Drawables.
> > > > If you cache Drawables, you run the risk of memory leaks. Drawables
> > > > have handles to your activity and when your activity gets destroyed
> > > > while your Drawables are still cached, your activiy will never be
> > > > garbage collected --> memory leak.
> > > > Bitmaps don't have this problem. They are basically byte-arrays with
> > > > some behavior :).
>
> > > > On Mar 25, 3:15 am, beachy <[email protected]> wrote:
>
> > > > > In some code I call this;
> > > > > Intent photoPickerIntent =
> > > > > new Intent
> > > > > (Intent.ACTION_PICK);
> > > > >
> > > > > photoPickerIntent.setType("image/*");
> > > > >
> > > > > startActivityForResult(photoPickerIntent,
> > > > > 1);
>
> > > > > then implement this method....
>
> > > > > protected void onActivityResult(int requestCode, int resultCode,
> > > > > Intent intent)
> > > > > {
> > > > > super.onActivityResult(requestCode, resultCode, intent);
>
> > > > > if (resultCode == RESULT_OK)
> > > > > {
> > > > > Uri photoUri = intent.getData();
> > > > > Log.d(TAG, "should be adding a photo");
> > > > > if (photoUri != null)
> > > > > {
>
> > > > > Log.d(TAG, "photo uri is not blank");
> > > > > // do something with the content Uri
> > > > > //TODO figure out why this does not
> > > > > work!!
> > > > > Log.d(TAG, "the photo URI is " +
> > > > > photoUri.getPath());
> > > > > Drawable thePic = Drawable.createFromPath
> > > > > (photoUri.getPath());
> > > > > //thePic is Null
> > > > > if(thePic != null){
> > > > > Log.d(TAG, "the pic has loaded");
> > > > > myRecipe.addPic(thePic);
> > > > > ((RecipeAdapter)myListView.getAdapter
> > > > > ()).notifyDataSetChanged();
>
> > > > > }
> > > > > }
> > > > > }
> > > > > }
>
> > > > > trying to get aimageand load it in to a drawable object. The Uri
> > > > > that is returned seems logical
>
> > > > > 03-25 08:12:58.554: DEBUG/ConvertScaleScreen(174): the photo URI is /
> > > > > external/images/media/1
>
> > > > > but when i start up a shell with adb the file location or even the
> > > > > root drive does not exitst, am I missing something here? should the be
> > > > > a symbolic link on the file system?- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---