startActivity within a subclass of Application

后端 未结 2 1404
清歌不尽
清歌不尽 2020-12-31 22:50

I have a little Android application in which I specify my application directly and do some application-wide setup in the ApplicationSubclass\' onCreate, but I am getting the

2条回答
  •  不思量自难忘°
    2020-12-31 23:26

    I have launch an activity(to relogin the user when loss the session) from my class which subclass from Application as follow:

    public boolean relogin(Activity act) {      
        Intent intent = new Intent(act,ActivityLogin.class);    
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);     
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
        startActivity(intent);              
        act.finish();// here i finish my current activity
    }
    

提交回复
热议问题