Got help from IRC.  I need to unregister the sensor when the activity
is exited.  That fixed the problem.

On Oct 27, 1:17 pm, AaronBC <[EMAIL PROTECTED]> wrote:
> I have 2 Activities, one is a main menu which will eventually have a
> list of multiple items (it currently only has 1 item).  When I click
> on that item it starts a new Activity like this:
>
> i = new Intent(this,PlayActivity.class);
> startActivity(i);
>
> The new Activity shows and ImageView like this:
>
> protected void onCreate(Bundle savedInstanceState)
> {
>   SensorManager mySensorManager;
>   super.onCreate(savedInstanceState);
>
>   mySensorManager =
> (SensorManager)this.getSystemService(SENSOR_SERVICE);
>   mySensorManager.registerListener(mSensorListener,
> SensorManager.SENSOR_ACCELEROMETER,
> SensorManager.SENSOR_DELAY_NORMAL);
>
>   setContentView(R.layout.animations_main_screen);
>
>   mImageView = (ImageView) findViewById(R.id.picture);
>   mImageView2 = (ImageView) findViewById(R.id.picture2);
>   mContainer = (ViewGroup) findViewById(R.id.container);
>
>   mImageView.setClickable(true);
>   mImageView.setFocusable(true);
>   mImageView.setOnTouchListener(this);
>
>   mImageView2.setClickable(true);
>   mImageView2.setFocusable(true);
>   mImageView2.setOnTouchListener(this);
>
>   gameDeck = new Deck();
>   displayCard = gameDeck.GetNextCard();
>   mImageView.setImageResource(displayCard.getImageResource());
>
> }
>
> Here is the layout resource:
>
> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:id="@+id/container"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent">
>
>     <ImageView
>         android:id="@+id/picture"
>         android:scaleType="fitCenter"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent" />
>
>     <ImageView
>         android:id="@+id/picture2"
>         android:scaleType="fitCenter"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent"
>         android:visibility="gone" />
>
> </FrameLayout>
>
> Okay, when I click the menu item it starts the new activity just
> fine.  Once the Activity is started I press the "Back" button to
> return to the main menu.  If I do this about 30 times I will
> eventually get the following:
>
> 10-27 17:58:30.783: ERROR/dalvikvm-heap(201): 523520-byte external
> allocation too large for this process.
> 10-27 17:58:30.793: ERROR/(201): VM won't let us allocate 523520 bytes
>
> Thread [<3> main] (Suspended (exception OutOfMemoryError))
>         Resources.getDrawable(int) line: 499
>         ImageView.resolveUri() line: 468
>         ImageView.setImageResource(int) line: 263
>         PlayActivity.onCreate(Bundle) line: 53
>         Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1122
>         ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord)
> line: 2103
>         ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord)
> line: 2156
>         ActivityThread.access$1800(ActivityThread, ActivityThread
> $ActivityRecord) line: 112
>         ActivityThread$H.handleMessage(Message) line: 1580
>         ActivityThread$H(Handler).dispatchMessage(Message) line: 88
>         Looper.loop() line: 123
>         ActivityThread.main(String[]) line: 3742
>         Method.invokeNative(Object, Object[], Class, Class[], Class, int,
> boolean) line: not available [native method]
>         Method.invoke(Object, Object...) line: 515
>         ZygoteInit$MethodAndArgsCaller.run() line: 739
>         ZygoteInit.main(String[]) line: 497
>         NativeStart.main(String[]) line: not available [native method]
>
> Each image that is shown is around 50K.  Am I suppose to do some
> garbage clean-up when the back button is pressed?  I can't figure out
> what I'm doing wrong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to