Hello I have a Main activity and this mainactivity has a mainview. This mainview is a surfaceview. For rendering the logic to draw on the surface view teh mainview has a mainthread.
So now I have a Problem which I hadn't before: The first App I make in landscape so I set all activities' orientation to landscape.
When the App now gets through onDestroy the Mainview gets null.
And I dont get why!!!
Here the onCretae:
MainView mView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(mView==null)
Log.e("","mainview==nullllll");
if(savedInstanceState==null)
{
mView=new MainView(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(mView);
}
}
and here the onDestroy:
@Override
public void onDestroy()
{
super.onDestroy();
if(mView==null)
Log.e("","mainview==nullllll");
}
What can I do to prevent my Mainview to be nullified? having two mainviews so to make sure it doesnt get garbage collected and refill the nullified one?
I dont want to set up the thread and the view every time.
I wonder why the Activity gets Destroyed on the other hand. I'm just locking the screen and in my other apps(where the Screen orientation is locked to portrait) doesn't behave like that it doesnt get into the destroy method if it is not really destroyed. It should get into the stopped state and wait there to be resumed again and not getting destroyed!
Please help me guys!