开发者

How to call the activity running on the top from Thread class

开发者 https://www.devze.com 2023-04-04 13:43 出处:网络
I am trying to start a thread in every activty oncreate method and after certain timei want to finish the activty from the thre开发者_如何学Cad calss using finish() method but finish method needs to e

I am trying to start a thread in every activty oncreate method and after certain time i want to finish the activty from the thre开发者_如何学Cad calss using finish() method but finish method needs to extend activty class.so, how can i get the activty on top in my thread class..?


Parse the activity to the thread in its constructor:

public MyThread( Activity activity ) {
   this.activity = activity;
}

And when you want to end the activity from the thread-class you call:

activity.finish();
0

精彩评论

暂无评论...
验证码 换一张
取 消