ACTION_TIME_CHANGED or ACTION_DATE_CHANGED, can't make them work

前端 未结 6 1523
小鲜肉
小鲜肉 2021-01-14 12:43

So I am in the process of trying to get a few intents to work for me, and am having problems on 2 specific intents. I searched these groups and the webs and can \'t seem

6条回答
  •  天命终不由人
    2021-01-14 13:19

    Inside your broadcast receiver onReceive method I am assuming u have a similar setup to the following?

    @Override
    public void onReceive(Context context, Intent intent){
        final String action = intent.getAction();
        if (Intent.ACTION_DATE_CHANGED.equals(action) || Intent.ACTION_TIME_CHANGED.equals(action)){
        // do stuff here
        }
        ...
    }
    

    Another consideration would be did you add the proper filters to your IntentFilter such as...

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_DATE_CHANGED);
    

提交回复
热议问题