0

I am making an short-cut application for android. My application should open the built-in application selected by the user and exit.

For example, if the user selects "settings", Built-in settings application should be opened and my application should exit. I am able to accomplish the first task using intents. But when i use "finish()" to close my application. The process is still running in background. So when i relaunch my application from menu, the surface view is empty.

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings","com.android.settings.Settings");
context.startActivity(intent);
((Activity) context).finish();

Through google, i found code to force exit the application, but everywhere its advice not to force quit an application.

Where am i going wrong? why is the surface view empty when i relaunch the application?

1 Answers1

0

Use onDestroy() to close down the app.

sdfwer
  • 1,042
  • 3
  • 10
  • 23
  • The reason why finish didn't show everything is that you may have too much for the memory to recall back also some maybe from other classes. – sdfwer Mar 15 '12 at 20:46
  • finish() returns you to your previous activity by the way. If that activity has some missing data it gives out a blank screen. – sdfwer Mar 15 '12 at 20:47
  • onDestroy() should be included in the activity? but how to close the application in that? The application should not be running in the backgrounf – Kavin Boopbathy Mar 16 '12 at 20:11
  • hi sdfwer. I want to close my application completely including the activity. presently i am calling finish from the surfaceview. How to close my activity and the process? – Kavin Boopbathy Mar 16 '12 at 20:13
  • I found the problem in the application. After i call another activity and finish() on my surfaceview. The old activity is in "Paused" status. How to bring the activity to "resume" status or destroy the activity completely? – Kavin Boopbathy Mar 16 '12 at 20:37
  • http://stackoverflow.com/questions/4423671/why-super-ondestroy-in-java-android-goes-on-top-in-destructors – sdfwer Mar 16 '12 at 20:44