I am making an app with a login screen which then goes to a surfaceview where the game is played. The problem is that the user can be logged out while playing and I need to be able to return the user to the login screen. How would I do this?
I’ve tried adding this to the surfaceview, but it doesn’t do anything:
((Activity)getContext()).setContentView(R.layout.login);
EDIT:
Issue is solved, here is the code I added in surfaceview:
Intent intent = new Intent();
intent.setClass(getContext(), BattleLogin.class);
((Activity)getContext()).startActivityForResult(intent,loginResult);
It may be important to mention to, don’t forget to add the new activity to the manifest.
Why don’t you try creating an Intent to start a new Activity to handle user login? It would leave the previous Activity dedicated to the SurfaceView paused in the stack while the user interacts with the new screen.
You can use
startActivityForResult()which is detailed here anywhere in your SurfaceView Activity to obtain status information like successful login or something when your login Activity finishes.