Reclaim the ImageView after bitmap and the callback method before the activity is killed

Source: Internet
Author: User

Reclaim the ImageView after bitmap and the callback method before the activity is killed

1. Reclaim the ImageView after bitmap

1.11

ImageView imageView1 = (ImageView) findViewById (R. id. imageView1 );
Bitmap = BitmapFactory. decodeResource (getResources (), R. drawable. ic_launcher );
ImageView1.setImageBitmap (bitmap );
Bitmap. recycle ();

The content displayed in imageView1 is null.

1.12

ImageView imageView1 = (ImageView) findViewById (R. id. imageView1 );
Bitmap = BitmapFactory. decodeResource (getResources (), R. drawable. ic_launcher );
ImageView1.setImageBitmap (bitmap );

ImageView1.setOnClickListener (new OnClickListener (){

@ Override
Public void onClick (View v ){
StartActivity (new Intent (MainActivity. this, TwoActivity. class ));

}
});

@ Override
Protected void onStop (){
Super. onStop ();
System. out. println ("onStop ");
Bitmap. recycle ();
}

When the current activity is visible again, the content displayed in imageView1 is blank ........................, but no exception is thrown.

2. Callback method before activity death

2.11 The Methods triggered when you press the backend key include onBackPressed, onPause, onStop, and onDestroy.

2.12 The Methods triggered when the user finishes () the activity include: onPause, onStop, onDestroy

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.