An activity opens the SurfaceView class passing the context. I want to close de SurfaceView keeping the first activity alive.
((Activity) getContext()).finish();
This close the parent activity. How can I close only de SurfaceView ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re right, setContentView() should be called only once per Activity, in the onCreate() method. If you need to change the layout completely, then create another Activity, and you won’t run into problems like that.
So, to solve your problem, create a dedicated activity for your SurfaceView that you can close safely without worrying about closing your Stage Chooser in the same time.