Error in native method Picture.nativeCreateFromStream()

by nickthecook » Tue, 06 Jan 2009 01:20:17 GMT


Sponsored Links
 ello all,

I'm having some trouble creating a Picture from an InputStream. I am
trying to do this:

ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
Picture pic = Picture.createFromStream(bis);

The problem also occurs when I try to use an InputStream returned by
ContentResolver.openInputStream(Uri):

InputStream is = getContentResolver.openInputStream(mUri);
Picture pic = Picture.createFromStream(is);

Picture.createFromStream(InputStream) invokes the native method
Picture.nativeCreateFromStream(InputStream, byte[]), and this is where
the trail goes cold for me:

public static Picture createFromStream(InputStream stream) {
return new Picture(
nativeCreateFromStream(stream, new byte
[WORKING_STREAM_STORAGE]));
}

I have been loading images from this Uri ("content://media/external/
images/media/152") successfully for a while. I open an InputStream,
read all the bytes, close the input stream, and there is no problem.
However, when I try to use either the InputStream returned by
ContentResolver.openInputStream(Uri), or I read all the bytes out of
that and wrap them in a ByteArrayInputStream, Picture.createFromStream
(InputStream) fails with the stack trace below.

Has anyone successfully used Picture.createFromStream(InputStream)?

======= Stack Trace ========
I/dalvikvm-heap( 4776): Grow heap (frag case) to 5.940MB for 3000016-
byte allocation
D/dalvikvm( 4776): GC freed 371 objects / 20736 bytes in 89ms
I/Image ( 4776): Read 345682 bytes for
content://media/external/images/media/152.
I/DEBUG ( 29): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG ( 29): Build fingerprint: 'android-devphone1/
dream_devphone/dream/trout:1.0/UNLOCKED/116222:userdebug/test-keys'
I/DEBUG ( 29): pid: 4776, tid: 4776 >>> org.hopto.group18.postbot
<<<
I/DEBUG ( 29): signal 6 (SIGABRT), fault addr 000012a8
I/DEBUG ( 29): r0 00000000 r1 00000006 r2 00000000 r3 00000080
I/DEBUG ( 29): r4 00002eb0 r5 40008000 r6 00000000 r7 00000025
I/DEBUG ( 29): r8 beb0a630 r9 4104d9c8 10 4104d9b8 fp 00000000
I/DEBUG ( 29): ip ffffffff sp beb0a5c8 lr afe0ef37 pc
afe0d1fc cpsr 00000010
I/DEBUG ( 29): #00 pc afe0d1fc /system/lib/libc.so
I/DEBUG ( 29): #01 pc afe0ef34 /system/lib/libc.so
I/DEBUG ( 29): #02 pc ace08540 /system/lib/libcorecg.so
I/DEBUG ( 29): #03 pc ac075cec /system/lib/libsgl.so
I/DEBUG ( 29): #04 pc ad3413da /system/lib/
libandroid_runtime.so
I/DEBUG ( 29): #05 pc ad00d9f4 /system/lib/libdvm.so
I/DEBUG ( 29): #06 pc ad04120e /system/lib/libdvm.so
I/DEBUG ( 29): #07 pc ad012748 /system/lib/libdvm.so
I/DEBUG ( 29): #08 pc ad02a92c /system/lib/libdvm.so
I/DEBUG ( 29): #09 pc ad0169d0 /system/lib/libdvm.so
I/DEBUG ( 29): #10 pc ad052096 /system/lib/libdvm.so
I/DEBUG ( 29): #11 pc ad03ccbc /system/lib/libdvm.so
I/DEBUG ( 29): #12 pc ad012748 /system/lib/libdvm.so
I/DEBUG ( 29): #13 pc ad02a92c /system/lib/libdvm.so
I/DEBUG ( 29): #14 pc ad0169d0 /system/lib/libdvm.so
I/DEBUG ( 29): #15 pc ad051f10 /system/lib/libdvm.so
I/DEBUG ( 29): #16 pc ad03f87a /system/lib/libdvm.so
I/DEBUG



Error in native method Picture.nativeCreateFromStream()

by Mike Reed » Tue, 06 Jan 2009 01:39:37 GMT


 hat method should not crash (I will fix that), but it is only
intended to re-create a picture that was previously written to a
stream. It does not know how to decode or interpreted images or other
data formats. Use BitmapFactory for that.

On Sun, Jan 4, 2009 at 11:29 AM, nickthecook <nickthec...@gmail.com> wrote:

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


Sponsored Links


Error in native method Picture.nativeCreateFromStream()

by nickthecook » Tue, 06 Jan 2009 11:52:56 GMT


 s you say, it should not crash quite like that, but I see that I was
using it incorrectly now.

BitmapFactory does the job.

Thank you!

On Jan 5, 12:39pm, Mike Reed <r...@google.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. why is my app asking to access phone calls and storage?

I am having the same problem and I just want to confirm:

You are saying that when you try to install over the air (just by
downloading APK file) you get asked those permissions, but when your
application is installed through the Android Market - you are NOT
asked for PHONE_STATE and STORAGE? Is that correct?

APK over the air those permissions come up... (I have been banging my
head on the walls for quite some time now). On 1.5 they don't come up!
Not on the emulator and not on the device.

Regards,
Max.








-- 

2. Pickup a phone contact under the emulator

Dear All,



Quick question;



-          When running the 2.0 emulator, my application can pick-up a
phonebook contact anymore:

o   (1) when invoking an ACTION_PICK intent and when the agenda is empty, I
get a menu suggesting that when pressing the MENU key, I  be able to select
a account. No menu ever appears when I select the menu button 
o   (2) when an account is properly provisioned under the emulator and after
that a phone number is populated, if I invoke the Menu button and select
ccounts, I immediately get the following crash (without even using my
application):





W/UsageStats(   52): Failed to persist new stats

I/ContactsListActivity(  102): Called with action:
com.android.contacts.action.LIST_DEFAULT

I/ActivityManager(   52): Displayed activity
com.android.contacts/.DialtactsContactsEntryActivity: 1311 ms (total 1311
ms)

W/UsageStats(   52): Failed to persist new stats

W/KeyCharacterMap(  102): No keyboard for id 0

W/KeyCharacterMap(  102): Using default keymap:
/system/usr/keychars/qwerty.kcm.bin

I/ActivityManager(   52): Starting activity: Intent {
act=android.settings.SYNC_SETTINGS (has extras) }

D/AndroidRuntime(  102): Shutting down VM

W/dalvikvm(  102): threadid=3: thread exiting with uncaught exception
(group=0x4001b188)

E/AndroidRuntime(  102): Uncaught handler: thread main exiting due to
uncaught exception

E/AndroidRuntime(  102): android.content.ActivityNotFoundException: No
Activity found to handle Intent { act=android.settings.SYNC_SETTINGS (has
extras) }

E/AndroidRuntime(  102):        at
android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)

E/AndroidRuntime(  102):        at
android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)

E/AndroidRuntime(  102):        at
android.app.Activity.startActivityFromChild(Activity.java:2989)

E/AndroidRuntime(  102):        at
android.app.Activity.startActivityForResult(Activity.java:2769)

E/AndroidRuntime(  102):        at
android.app.Activity.startActivity(Activity.java:2855)

E/AndroidRuntime(  102):        at
com.android.contacts.ContactsListActivity.onOptionsItemSelected(ContactsListActivity.java:889)

E/AndroidRuntime(  102):        at
android.app.Activity.onMenuItemSelected(Activity.java:2170)

E/AndroidRuntime(  102):        at
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)

E/AndroidRuntime(  102):        at
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)

E/AndroidRuntime(  102):        at
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)

E/AndroidRuntime(  102):        at
com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:525)

E/AndroidRuntime(  102):        at
com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)

E/AndroidRuntime(  102):        at
android.view.View.onTouchEvent(View.java:4179)

E/AndroidRuntime(  102):        at
android.widget.TextView.onTouchEvent(TextView.java:6532)

E/AndroidRuntime(  102):        at
android.view.View.dispatchTouchEvent(View.java:3709)

E/AndroidRuntime(  102):        at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)

E/AndroidRuntime(  102):        at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)

E/AndroidRuntime(  102):        at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)

E/AndroidRuntime(  102):        at
android.view.ViewRoot.handleMessage(ViewRoot.java:1690)

E/AndroidRuntime(  102):        at
android.os.Handler.dispatchMessage(Handler.java:99)

E/AndroidRuntime(  102):        at android.os.Looper.loop(Looper.java:123)

E/AndroidRuntime(  102):        at
android.app.ActivityThread.main(ActivityThread.java:4310)

E/AndroidRuntime(  102):        at
java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(  102):        at
java.lang.reflect.Method.invoke(Method.java:521)

E/AndroidRuntime(  102):        at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)

E/AndroidRuntime(  102):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

E/AndroidRuntime(  102):        at dalvik.system.NativeStart.main(Native
Method)

I/Process (   52): Sending signal. PID: 102 SIG: 3

I/dalvikvm(  102): threadid=7: reacting to signal 3

E/dalvikvm(  102): Unable to open stack trace file '/data/anr/traces.txt':
Permission denied

E/ActivityThread(   52): Failed to find provider info for
android.server.checkin

E/Checkin (   52): Error reporting crash:
java.lang.IllegalArgumentException: Unknown URL
content://android.server.checkin/crashes







Van somebody take a look at this on the Android team and also suggest what
Intent an application needs to fire for a user to (A) enter a proper sync
account and (B) retrieve a phone contact from a phone-entry associated with
this account. I don think that this burden should be handle by end-user
apps and the latest SDK convey no relevant explanation to even to that
properly.



Having the fact that the emulator crashes shows that whatever new mechanism
is in place to have app access phone entry is not working.



FL

-- 

3. Develop app targeting both 1.6 and 2.0

4. Can anyone tell me ONE app that shows up in Android Market on HTC Tattoo

5. Multi-touch on Eclair

6. getsystemservice for notification service returns null

7. Can an Activity pause() rather than finish()?