Finishing an Activity from a Broadcast Receiver

前端 未结 5 1770
夕颜
夕颜 2020-12-01 18:49

I have an Activity that I display as modeless when the phone rings (over the phone app). I would like to finish the Activity when either of the following events occur. The f

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 19:47

    After a long R&D over internet i have solved my problem. The below code is helpful if you start an activity from broadcast receiver and clear all activity stack instance.

     @Override
        public void onBackPressed() {
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                moveTaskToBack(true);
            }
        }
    

提交回复
热议问题