根据日期创建显示文本消息的小组件

时间:2016-12-26 06:54:28

标签: android

我想创建一个小部件,根据日期显示文本消息。我的问题是我不知道如何检测系统何时更改日期。

我的代码:

public class AlarmReceiver extends BroadcastReceiver { 
  MediaPlayer mp = null;// Here int m,n; 
  @Override public void onReceive(Context context, Intent intent) {
     String action = intent.getAction(); 
     if (action.equals(Intent.ACTION_DATE_CHANGED)) { // new
       MainActivity().setSunrise(); 
       Toast.makeText(context, "deteced date change", Toast.LENGTH_SHORT).show();
     } 

public class AlarmReceiver extends BroadcastReceiver {
  int m,n;
  @Override public void onReceive(Context context, Intent intent) {
     String action = intent.getAction();
     if (action.equals(Intent.ACTION_DATE_CHANGED)) {
       Toast.makeText(context, "deteced date change", Toast.LENGTH_SHORT).show();
     }
  }
}

0 个答案:

没有答案