Prevent Activity to recreated Another most common solution to dealing with orientation changes by setting the android:configChanges flag on your Activity in AndroidManifest. xml. Using this attribute your Activities won't be recreated and all your views and data will still be there after orientation change.
If you want to manually handle orientation changes in your app you must declare the "orientation" , "screenSize" , and "screenLayout" values in the android:configChanges attributes. You can declare multiple configuration values in the attribute by separating them with a pipe | character.
When you rotate your device and the screen changes orientation, Android usually destroys your application's existing Activities and Fragments and recreates them . Android does this so that your application can reload resources based on the new configuration.
how i can stop the restarting or recalling of on create() on screen orientation ,i want to stop the recreation of activity on screen orientation. thanks in advance please tell me any better solution its really creating a problem. like in my program i am selecting some picture but on screen orientation the image goes off so thats why i want to stop the recreation of activity on screen orientation.
enter code here
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mainwindow);
Toast.makeText(getApplicationContext(),"a", 1).show();
bitmap = (Bitmap)getLastNonConfigurationInstance();
//Toast.makeText(getApplicationContext(),"a1", 1).show();
if (savedInstanceState != null)
{
bitmap=BitmapFactory.decodeFile(mImageCaptureUri.getPath());
Toast.makeText(getApplicationContext(),"preview have value", 1).show();
preview.setVisibility(View.VISIBLE);
From_Folder.setVisibility(View.GONE);
From_Camera.setVisibility(View.GONE);
preview.setImageBitmap(bitmap);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With