Android - detecting application launch from home or history

前端 未结 4 1077
野趣味
野趣味 2020-11-29 10:18

What is the best way to detect when an Android \"Application\" has been launched from the Home screen/History screen?

Basically, what I\'m trying to achieve is force

4条回答
  •  被撕碎了的回忆
    2020-11-29 11:04

    simply create a stump activity that doesn't have a content view and launches other activities on application start

    e.g. put the following into onCreate:

    Class myclass;
    
    if(isTimeForActivity1){
        myclass = Activity1.class;
    }else if(isTimeForActivity2){
        myclass = Activity2.class;
    }
    
    startActivity(new Intent(this, myclass));
    finish();
    

提交回复
热议问题