Re: dumb(?) book question...

19 views
Skip to first unread message

Shawn Van Every

unread,
Feb 8, 2011, 5:33:21 PM2/8/11
to ambrose lewis, android-medi...@googlegroups.com
Hi,

There isn't a forum setup as of right now. Perhaps a Google Group would be the way to go. Do you have any thoughts about that? Actually, I just created one and am cross-posting this to that group. (http://groups.google.com/group/android-media-developers)

Not a dumb question at all. I think the issue is that it assumes an SD card is available and mounted by your device. Any chance yours is removed? (It could automatically be mounted by your computer when you connect via USB and therefore unavailable on the phone itself.)

You could try using the INTERNAL_CONTENT_URI instead which will attempt to store the image in the internal phone memory rather than the SD card.

Let me know (hopefully via the android-media-developers group) how it goes.

Best,
shawn

On Feb 8, 2011, at 4:59 PM, ambrose lewis wrote:

> Hi Shawn:
> Very excited about your Android Media book...I just got it yesterday and it seems like it will be a big help!
>
> I'm running into a issue with the second program...is there some forum to ask questions about the book?
> My development environment is a windows pc/eclipse and a Verizon Droid 2 (Version 2.3.20.A955.Verizon.en.US) connected via USB.
> I downloaded the source code from the book's APress page and imported them into eclipse as android applications. When I try to run "Pro Android Media Ch 1 - MediaStore Camera Intent", I get the following error:
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): java.lang.UnsupportedOperationException: Unknown URI: content://media/external/images/media
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:1859)
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1801)
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): at android.content.ContentProvider$Transport.insert(ContentProvider.java:174)
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:168)
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): at android.os.Binder.execTransact(Binder.java:304)
> 02-08 16:50:04.113: ERROR/DatabaseUtils(1425): at dalvik.system.NativeStart.run(Native Method)
> I used log statements to zero in on the line:
>
> imageFileUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
>
> Any ideas???
>
> Sorry if this is a dumb question
>
> amb
>

Shawn Van Every
vane...@walking-productions.com
Mobile and Streaming Consulting
http://www.walking-productions.com/notslop
Author: Pro Android Media: http://amzn.to/eYb48C

amb

unread,
Feb 8, 2011, 6:07:47 PM2/8/11
to Android Media Developers
Here was my original question...
On Feb 8, 5:33 pm, Shawn Van Every <vanev...@walking-productions.com>
wrote:
> vanev...@walking-productions.com
> Mobile and Streaming Consultinghttp://www.walking-productions.com/notslop

Shawn Van Every

unread,
Feb 8, 2011, 7:21:05 PM2/8/11
to android-medi...@googlegroups.com
Hi amb,

Thanks for the repost. Were you able to resolve the issue?

I have heard (I haven't used a Droid myself) that it might automount the SD card on your computer and therefore it would be unavailable on the phone making anything that attempts to use it during that time fail.

-s

Shawn Van Every


vane...@walking-productions.com
Mobile and Streaming Consulting

amb

unread,
Feb 9, 2011, 9:18:46 AM2/9/11
to Android Media Developers
Hi Shawn:
I tried setting the USB to "charge only", which should keep the SD
card mounted to the device and still see the problem on my Droid 2.
I also tried running on an emulator and I still get a force close.
Could this have something to do with permissions to write to the SD
card?
I'll poke around some more tonight.
Thanks for the help and the follow up!
amb

On Feb 8, 7:21 pm, Shawn Van Every <vanev...@walking-productions.com>
> Author: Pro Android Media:http://amzn.to/eYb48C- Hide quoted text -
>
> - Show quoted text -

Shawn Van Every

unread,
Feb 9, 2011, 9:22:46 AM2/9/11
to android-medi...@googlegroups.com
Hmmn. It shouldn't have anything to do with permissions.

Any chance you tried it with the INTERNAL_CONTENT_URI rather than the EXTERNAL_CONTENT_URI?

I'll have to try this out on a Droid and report back.

Shawn Van Every


vane...@walking-productions.com
Mobile and Streaming Consulting

amb

unread,
Feb 9, 2011, 1:32:26 PM2/9/11
to Android Media Developers
Hi Shawn:
I made the suggested changed and tried it on the device and on the
emulator.
Here is the line (as modified):
Log.d("mediaStore","before getContentResolver...");
//imageFileUri = getContentResolver().insert(
// Media.EXTERNAL_CONTENT_URI, new ContentValues());
imageFileUri = getContentResolver().insert(
Media.INTERNAL_CONTENT_URI, new ContentValues());
Log.d("mediaStore","after getContentResolver...");
In both cases, I get the following:
02-09 13:22:09.709: DEBUG/mediaStore(4754): before
getContentResolver...
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): Writing exception to
parcel
02-09 13:22:09.733: ERROR/DatabaseUtils(1422):
java.lang.UnsupportedOperationException: Writing to internal storage
is not supported.
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
com.android.providers.media.MediaProvider.generateFileName(MediaProvider.java:
2332)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
com.android.providers.media.MediaProvider.ensureFile(MediaProvider.java:
1752)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:
1870)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
com.android.providers.media.MediaProvider.insert(MediaProvider.java:
1801)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
android.content.ContentProvider$Transport.insert(ContentProvider.java:
174)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
android.content.ContentProviderNative.onTransact(ContentProviderNative.java:
168)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
android.os.Binder.execTransact(Binder.java:304)
02-09 13:22:09.733: ERROR/DatabaseUtils(1422): at
dalvik.system.NativeStart.run(Native Method)
02-09 13:22:09.733: DEBUG/AndroidRuntime(4754): Shutting down VM




On Feb 9, 9:22 am, Shawn Van Every <vanev...@walking-productions.com>
> >> Author: Pro Android Media:http://amzn.to/eYb48C-Hide quoted text -

Shawn Van Every

unread,
Feb 9, 2011, 1:53:33 PM2/9/11
to android-medi...@googlegroups.com
I am sorry to say that I don't know what the issue is. I can understand that the INTERNAL_CONTENT_URI doesn't work but the EXTERNAL_CONTENT_URI should work.

What version of Android is your Droid 2 running?

Attached is an updated version of the project. If you could run it and give the logcat output I would appreciate it.


MediaStoreCameraIntentTesting.zip

amb

unread,
Feb 10, 2011, 7:22:12 AM2/10/11
to Android Media Developers
Yeah!

I tried the example you kindly posted with my existing AVD (platform
2.3 / API level 9) and I get a force close.
On my phone, it doesn't work either (error pasted below). According
to Settings>About Phone, my Android Version is 2.2 and my System
Version is 2.3.20.A955.Verizon.en.US.

Next, I made and started a new AVD with a platform =1.6 and API level
= 4. The example program you posted runs fine!

I tried two other AVDs:
Runs fine with platform = 2.1 update 1 and API level = 7
BUT, it dies with platform = 2.2 and API level = 8

So, I wonder what changed between API level 7 and API level 8???

Thanks again for all the help...
amb


error from the phone:
02-10 07:17:41.790: DEBUG/skia(8781): --- SkImageDecoder::Factory
returned null
02-10 07:17:41.790: WARN/dalvikvm(8781): threadid=8: thread exiting
with uncaught exception (group=0x400208b0)
02-10 07:17:41.805: ERROR/AndroidRuntime(8781): FATAL EXCEPTION:
Thread-10
02-10 07:17:41.805: ERROR/AndroidRuntime(8781):
java.lang.NullPointerException
02-10 07:17:41.805: ERROR/AndroidRuntime(8781): at
com.motorola.Camera.Camera$UpdateThumbnailRunnable.run(Camera.java:
3877)
02-10 07:17:41.837: WARN/ActivityManager(1238): Force finishing
activity com.motorola.Camera/.Camera
02-10 07:17:41.837: INFO/Process(8781): Sending signal. PID: 8781 SIG:
9
02-10 07:17:41.837: ERROR/ANRInfo(1238): Force Close Dialog not
Displayed - showDialog=false mSleeping=false


On Feb 9, 1:53 pm, Shawn Van Every <vanev...@walking-productions.com>
wrote:
> I am sorry to say that I don't know what the issue is.  I can understand that the INTERNAL_CONTENT_URI doesn't work but the EXTERNAL_CONTENT_URI should work.
>
> What version of Android is your Droid 2 running?
>
> Attached is an updated version of the project.  If you could run it and give the logcat output I would appreciate it.
>
>  MediaStoreCameraIntentTesting.zip
> 70KViewDownload
>
>
>
> On Feb 9, 2011, at 1:32 PM, amb wrote:
>
>
>
>
>
> > Hi Shawn:
> > I made the suggested changed and tried it on the device and on the
> > emulator.
> > Here is the line (as modified):
> >                            Log.d("mediaStore","before getContentResolver...");
> >                            //imageFileUri = getContentResolver().insert(
> >                            //              Media.EXTERNAL_CONTENT_URI, new ContentValues());
> >                            imageFileUri = getContentResolver().insert(
> >                                            Media.INTERNAL_CONTENT_URI, new ContentValues());
> >                            Log.d("mediaStore","after getContentResolver...");
> > In both cases, I get the following:
> > 02-09 13:22:09.709: DEBUG/mediaStore(4754): before
> > getContentResolver...
> > 02-09 13:22:09.733: ERROR/DatabaseUtils(1422): Writing exception to
> > parcel
> > 02-09 13:22:09.733: ERROR/DatabaseUtils(1422):
> > java.lang.UnsupportedOperationException: Writing to internal storage
> > is not supported.
> > 02-09 13:22:09.733: ERROR/DatabaseUtils(1422):     at
> > com.android.providers.media.MediaProvider.generateFileName(MediaProvider.ja­va:
> >>>> Author: Pro Android Media:http://amzn.to/eYb48C-Hidequoted text -
Reply all
Reply to author
Forward
0 new messages