You haven't shown us enough of your code (code snippets) for us to
begin figuring out what may be wrong with your app. Could you provide
more details?

But to your questions;
1. The onCreate is called once per Activity instance.
If you have instance-variables/fields in you activity, you can assume
they are null/0/false when you onCreate is being called.
But since many instances of your activity can exists, the onCreate can
be called multiple times (once per instance activity).

2. Before the onCreate, memory has been created and is in use by the
system.

On Oct 2, 6:14 pm, Yahel <[email protected]> wrote:
> Hi all,
>
> I'm having a hard time resolving a crash report.
> It's an OutOfMemory exception that occurs during the setContentView in
> the onCreate of my main activity.
>
> I just want to be sure I understood Android LifeCycle well :
>
> 1) The onCreate of my main activity is called once and only once
> during the life time of my application ? Is that correct ?
>
> 2) Just like for the big bang, before the oncreate of my activity,
> nothing exists for that activity, so memory consumption is zero, no
> objects exists right ?
>
> So what can cause that sometimes, with random framework and devices, I
> get an OOM exception ?
> I mean if say my background image  is causing this, it should blow up
> everytime, on every device, shouldn't it ? I mean the result should be
> reliable.
>
> The background image is a standard jpg : 360*480 weighing 37kb,
> nothing fancy really :s
>
> The crash report below :
>
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{com.kayenko.awof/com.kayenko.awof.Main}:
> android.view.InflateException: Binary XML file line #10: Error
> inflating class <unknown>
>         at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2663)
>         at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 2679)
>         at android.app.ActivityThread.access$2300(ActivityThread.java:125)
>         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
> 2033)
>         at android.os.Handler.dispatchMessage(Handler.java:99)
>         at android.os.Looper.loop(Looper.java:123)
>         at android.app.ActivityThread.main(ActivityThread.java:4627)
>         at java.lang.reflect.Method.invokeNative(Native Method)
>         at java.lang.reflect.Method.invoke(Method.java:521)
>         at com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:868)
>         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
>         at dalvik.system.NativeStart.main(Native Method)
> Caused by: android.view.InflateException: Binary XML file line #10:
> Error inflating class <unknown>
>         at android.view.LayoutInflater.createView(LayoutInflater.java:513)
>         at
> com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayo­utInflater.java:
> 56)
>         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:
> 563)
>         at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
>         at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.jav­a:
> 198)
>         at android.app.Activity.setContentView(Activity.java:1647)
> ------------------------
>         at com.kayenko.awof.Main.onCreate(Main.java:174)
> ------------------------
>         at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1047)
>         at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2627)
>         ... 11 more
> Caused by: java.lang.reflect.InvocationTargetException
>         at android.widget.FrameLayout.<init>(FrameLayout.java:79)
>         at java.lang.reflect.Constructor.constructNative(Native Method)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
>         at android.view.LayoutInflater.createView(LayoutInflater.java:500)
>         ... 22 more
> Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
>         at android.graphics.Bitmap.nativeCreate(Native Method)
>         at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
>         at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
>         at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
>         at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:
> 488)
>         at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:
> 462)
>         at
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:
> 323)
>         at
> android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:
> 697)
>         at android.content.res.Resources.loadDrawable(Resources.java:1709)
>         at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
>         at android.view.View.<init>(View.java:1885)
>         at android.view.ViewGroup.<init>(ViewGroup.java:291)
>         at android.widget.FrameLayout.<init>(FrameLayout.java:83)
>         ... 26 more
>
> Thanks for any hint.
>
> Yahelhttp://www.a-world-of-faces

-- 
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

Reply via email to