Notification shows after android app is force closed

后端 未结 4 2018
[愿得一人]
[愿得一人] 2020-12-21 15:13

I have googled this non stop today and could not find anything. My scenario is the following:

I have an Android app that auto replies to incoming messages. I have

4条回答
  •  Happy的楠姐
    2020-12-21 15:48

    The method that I used to kill the processes when I swipe apps from the recents is: in the first activity of the app, in the method OnDestroy I write that "the process have to kill". In this way I call the OnDestroy method of the process and so the process really kills himself and the notification is removed. Specifically, in the first Activity:

        @Override
    public void onDestroy() {
      super.onDestroy();
    
      Intent intent = new Intent();
      intent.setAction(Service.MY_ACTION_FROMACTIVITY);
      intent.putExtra(Service.CMD, Service.CMD_STOP);
      sendBroadcast(intent);
    
    }
    

    So the following operations are:

    @Override
    public void onDestroy() {
        // TODO Auto-generated method stub
        barNotification.cancel(NOTIFICATION);
    
        sensorManager.unregisterListener(this);
    
        this.unregisterReceiver(myServiceReceiver);
        super.onDestroy();
    }
    

    I hope that I can help you.

提交回复
热议问题