I have Dialog
on transparent activity and it's like a pause menu, so when dialog is shown and I press Home
button everything works fine but when I reopen it Dialog
shows, except the background is blank. Game is made with canvas
and SurfaceView
so I can't display Dialog
on that screen or can I, because I was trying but I get error every time
So when I press back key Dialog
shows perfectly:
But when I click Home button and that long click on Home button to reopen app I get this:
onResume code:
@Override
protected void onResume() {
super.onResume();
ourSurfaceView.resume();
}
public void resume() {
isRunning = true;
ourThread = new Thread(this);
ourThread.start();
}
Activity which shows Dialog
:
public class ShowPopUp extends Activity {
Dialog myDialog;
GameSurface ourSurfaceView;
Button toMenu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showpopupmain);
myDialog = new Dialog(ShowPopUp.this);
myDialog.setContentView(R.layout.showpopup);
myDialog.setTitle("Paused");
myDialog.setCancelable(true);
Button button = (Button) myDialog.findViewById(R.id.Btn1);
toMenu = (Button)myDialog.findViewById(R.id.Btn2);
toMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
Intent menu = new Intent(
"com.example.mygame.Menu");
startActivityForResult(menu, 5);
}
});
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
myDialog.dismiss();
finish();
}
});
myDialog.show();
myDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
ShowPopUp.this.finish();
}
});
}
}