I want to make a test app, that when called, execute a few lines of code, and then exit automatically. I want all these done within onCreate().
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("onCreate()");
try {
initSocket(); //connect to server
} catch (IOException e) {
e.printStackTrace();
}
new Thread(new AudioRecordThread()).start();
}
The problem is, how can I exit the app in onCreate()? I tried "this.finish()" but didn't work.
Any one can help?
EDIT I agree that the problem may be caused by thread. Will post my answer when solved.