如何在特定时间发送通知? (E.G上午9:00)

时间:2014-04-30 15:36:26

标签: eclipse notifications

您好我有一个应用程序,我希望在每天的特定时间发送特定的编辑框。例如,上午9点我有英语。目前我一直在使用这段代码,但它需要xml中的一个按钮。

如何使用此代码不使用按钮而是使用特定时间?

非常感谢(下面的代码)

public class Week1_Mon extends Activity {

       NotificationManager NM;
       EditText tit,sub,three;


       @Override
       protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.week1_mon);

            tit = (EditText)findViewById(R.id.week1_mon1);
            sub = (EditText)findViewById(R.id.week1_mon1);
            three = (EditText)findViewById(R.id.week1_mon6);
            editBox1=(EditText)findViewById(R.id.week1_mon1);
            editBox2 =(EditText)findViewById(R.id.week1_mon2);
            editBox3 =(EditText)findViewById(R.id.week1_mon3);
            editBox4 =(EditText)findViewById(R.id.week1_mon4);
            editBox5 =(EditText)findViewById(R.id.week1_mon5);
            editBox6 =(EditText)findViewById(R.id.week1_mon6);
            editBox7 =(EditText)findViewById(R.id.week1_mon7);
            editBox8 =(EditText)findViewById(R.id.week1_mon8);
            editBox_9 =(EditText)findViewById(R.id.week1_mon9);
            editBox10 =(EditText)findViewById(R.id.week1_mon10);
            }


       @Override
       public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
       }


       @SuppressWarnings("deprecation")
       public void notify(View vobj){
          String title = tit.getText().toString();
          String subject = sub.getText().toString();
          String body = three.getText().toString();
          NM=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
          Notification notify=new Notification(android.R.drawable.
          stat_notify_more,title,System.currentTimeMillis());
          PendingIntent pending=PendingIntent.getActivity(
          getApplicationContext(),0, new Intent(),0);
          notify.setLatestEventInfo(getApplicationContext(),subject,body,pending);
          NM.notify(0, notify);
       }

0 个答案:

没有答案