Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6023019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:56:36+00:00 2026-05-23T03:56:36+00:00

I am implementing SensorEventListner in my activities. I am having three activities where SensorEventListner

  • 0

I am implementing SensorEventListner in my activities.
I am having three activities where SensorEventListner is implementing to detect shake motion. In all three activities differently, I am registering the sensorListner onCreate and unregistering the listner onPause. On call of every activity it registers again and then `unregisters onPause.

My app having allocated heap size as 3.6MB while heap size of device is 16MB still getting Force close with the error in LogCat as:

” OutOfMemoryException: bitmap size exceeds VM budget”
EDIT: Logcat error

06-13 15:47:35.056: ERROR/AndroidRuntime(10377): Uncaught handler: thread main exiting due to uncaught exception
06-13 15:47:35.196: ERROR/AndroidRuntime(10377): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:464)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:340)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.content.res.Resources.loadDrawable(Resources.java:1705)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.content.res.Resources.getDrawable(Resources.java:580)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.widget.ImageView.resolveUri(ImageView.java:548)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.widget.ImageView.setImageResource(ImageView.java:270)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at com.nga.flashcards.activities.GardenActivity.display(GardenActivity.java:1024)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at com.nga.flashcards.activities.GardenActivity.onSensorChanged(GardenActivity.java:1352)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.hardware.SensorManager$ListenerDelegate$1.handleMessage(SensorManager.java:435)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.os.Looper.loop(Looper.java:123)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at android.app.ActivityThread.main(ActivityThread.java:4595)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at java.lang.reflect.Method.invoke(Method.java:521)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-13 15:47:35.196: ERROR/AndroidRuntime(10377):     at dalvik.system.NativeStart.main(Native Method)

I am also having large amount images and changing images in imageview through setImageResource(). Getting error on using SensorEventListner. If sensor event is not used in app then working fine.

My questions are :

  • Wheather there are any issues related to memory while registering and unregistering listener again and again in the app?

  • Are there any memory leaks, if yes then how to detect and what can be the solution to the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:56:36+00:00Added an answer on May 23, 2026 at 3:56 am

    Your problem is in your GardenActivity.display() method where you are calling setImageResource. It is this that is causing your problem. Maybe check the size of the image that you’re using, and reduce it.

    To prove that this is correct, comment out the call to display() from within your onSensorChanged() method, and you’ll find that it will work. Thus proving that it is not the sensor framework that’s at fault, but it is something that you’re doing within your event handler that’s causing the problem (as I mentioned in my earlier comments).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im implementing a pool billiard game in Java and it all works fine. It
Am implementing Sieve of Eratosthenes in CUDA and am having a very weird output.
Im implementing a recursive routine to calculate all the terms of a multinomial expression,
Implementing a custom Dependency Property on a Framework Element object causes my Visual Studio
Implementing the ScriptControlClass was extremely easy, unfortunately the side effects with the language implementation
implementing publishActivity in PHP using the REST API using this code: $activity = array(
Implementing a custom membership provider, there are certain properties such as MinRequiredPasswordLength that only
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
When implementing Serializable interface, in Java, we need to set it's serialVersionUID long. Is
when implementing a recursive function during development, i will use a counter and exit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.