I have this two methods, and I what to put in pause this main activity when “something1*” happens and then change to someactivity1* while the main activity is paused. But my problem is that it doesn’t change my activity, it freezes my main activity and it doesn’t do anything else. It’s probabli because I destroyed the thread but I can’t see any solution and I’m not sure. (The method2 is inside a loop)
sorry for my english and thanks for the help
public void method1(){
super.onPause();
run = false;
while(){
try{
thread.join();
}catch(InterruptedException e){
e.printStackTrace();
}
}
thread1 = null;
Intent i = new Intent(someactivity1*);
startActivity(i);
}
//the method2 is inside a loop
public void method2(){
if(something1*){
onPause();
}
}
You say
thread.join(). This makes the main thread, aka the UI thread, wait for the Thread calledthreadto finish. In other words, you’re locking your application with that.Why do you want to manage pausing your app anyway? Android manages everything itself. Just start Activities, and don’t call
onPause()anywhere in your methods except for theYourActivity.onPause().