Note that there are some explanatory texts on larger screens.

plurals
  1. POImageView not retaining Image when Screen rotation occurs
    primarykey
    data
    text
    <pre><code>import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Parcelable; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends Activity { ImageView iv; Bitmap bTemp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button cameraClick = (Button) findViewById(R.id.click); iv = (ImageView) findViewById(R.id.imageView1); final Bitmap data = (Bitmap) getLastNonConfigurationInstance(); if (data == null) { iv.setImageBitmap(bTemp); } cameraClick.setOnClickListener(myhandler); } OnClickListener myhandler = new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 0); } }; @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Bitmap bm = (Bitmap) data.getExtras().get("data"); iv.setImageBitmap(bm); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override @Deprecated public Object onRetainNonConfigurationInstance() { bTemp = iv.getDrawingCache(); return bTemp; } } </code></pre> <p>I'm using a imageview to store the image which is captured using the Camera Intent but when the screen rotates the image is lost. I tried using onRetainNonConfigurationInstance() but its not working </p> <p>And i don't want to write the image to afile.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload