Differentiating between an Activity launch from home screen or from another activity from App

前端 未结 7 1274
借酒劲吻你
借酒劲吻你 2020-12-09 03:51

I need to know a generic way to distinguish between a call of activity from launcher and a call from another activity from inside my app, or a BACK on the activity stack

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 04:33

    You can find it out from intent flag.

    step 1:

      Intent intent = getIntent();
      int flag = intent.getFlag();
    

    step 2:

    if flag  =  Intent.FLAG_ACTIVITY_NEW_TASK 
      launch from other app or activities
    else 
      launch from home page
    

提交回复
热议问题