如何在Android中以编程方式设置闹钟?

发布于 2024-11-17 14:20:36 字数 4351 浏览 5 评论 0原文

以下是我的代码,任何人都可以告诉我为什么它不起作用。我从 学到了它本教程。但它不起作用,任何帮助都是可观的。

我的代码是

import java.util.Calendar;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.ListActivity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;


public class Notify extends Activity {
    Button btn;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.nit);
        Calendar cal=Calendar.getInstance();
        cal.set(Calendar.MONTH,6);
        cal.set(Calendar.YEAR,2011);
        cal.set(Calendar.DAY_OF_MONTH,29);
        cal.set(Calendar.HOUR_OF_DAY,17);
        cal.set(Calendar.MINUTE,30);

        //String[] dude=new String[] {"nitin","avi","aman","rahul","pattrick","minkle","manmohan","nitin","nitin"};

        //setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,dude));
        //getListView().setTextFilterEnabled(true);

        //String[] dude1=new String[] {"nitin","avi","aman","rahul","pattrick","minkle","manmohan"};

        Intent intent = new Intent(this, Mote.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 1253, intent, PendingIntent.FLAG_UPDATE_CURRENT|  Intent.FILL_IN_DATA);

        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

        alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),pendingIntent );
        Toast.makeText(this, "Alarm worked.", Toast.LENGTH_LONG).show();
    }

}

,我的接收器类是

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class Mote extends BroadcastReceiver{

    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub

        Toast.makeText(context, "Alarm worked.", Toast.LENGTH_LONG).show();
        int icon = R.drawable.icon;
        CharSequence tickerText = "Hello you have to take medicine I am Nitin Sharma";
        long when = System.currentTimeMillis();

        //Notification notification = new Notification(icon, tickerText,when );

        CharSequence contentTitle = "My notification";
        CharSequence contentText = "Hello World!";


        //notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        final int NOTIF_ID = 1234;
        NotificationManager notofManager = (NotificationManager)context. getSystemService(Context.NOTIFICATION_SERVICE);
        // Notification note = new Notification(R.drawable.face,"NEW ACTIVITY", System.currentTimeMillis());
        Intent notificationIntent = new Intent(context, Alset.class);
        PendingIntent contentIntent = PendingIntent.getActivity(context,0, notificationIntent, 0);
        Notification notification = new Notification(icon, tickerText,when );
        //Notification notification1 = new Notification(R.drawable.icon, "Wake up alarm", System.currentTimeMillis());
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        notification.flags = Notification.FLAG_INSISTENT;
        notification.defaults |= Notification.DEFAULT_SOUND;
        //notification.setLatestEventInfo(context, "My Activity", "This will runs on button click", contentIntent);
        notofManager.notify(NOTIF_ID,notification);

        //PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
        //notification.setLatestEventInfo(context, "Context Title", "Context text", contentIntent);
        //notification.flags = Notification.FLAG_INSISTENT;
    }



}

Following is my code can Any body please tell me why it is not working .I have learned it from this tutorial. But it is not working any help will be appreciable.

My code is

import java.util.Calendar;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.ListActivity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;


public class Notify extends Activity {
    Button btn;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.nit);
        Calendar cal=Calendar.getInstance();
        cal.set(Calendar.MONTH,6);
        cal.set(Calendar.YEAR,2011);
        cal.set(Calendar.DAY_OF_MONTH,29);
        cal.set(Calendar.HOUR_OF_DAY,17);
        cal.set(Calendar.MINUTE,30);

        //String[] dude=new String[] {"nitin","avi","aman","rahul","pattrick","minkle","manmohan","nitin","nitin"};

        //setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,dude));
        //getListView().setTextFilterEnabled(true);

        //String[] dude1=new String[] {"nitin","avi","aman","rahul","pattrick","minkle","manmohan"};

        Intent intent = new Intent(this, Mote.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 1253, intent, PendingIntent.FLAG_UPDATE_CURRENT|  Intent.FILL_IN_DATA);

        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

        alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),pendingIntent );
        Toast.makeText(this, "Alarm worked.", Toast.LENGTH_LONG).show();
    }

}

and my Receiver class is

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class Mote extends BroadcastReceiver{

    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub

        Toast.makeText(context, "Alarm worked.", Toast.LENGTH_LONG).show();
        int icon = R.drawable.icon;
        CharSequence tickerText = "Hello you have to take medicine I am Nitin Sharma";
        long when = System.currentTimeMillis();

        //Notification notification = new Notification(icon, tickerText,when );

        CharSequence contentTitle = "My notification";
        CharSequence contentText = "Hello World!";


        //notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        final int NOTIF_ID = 1234;
        NotificationManager notofManager = (NotificationManager)context. getSystemService(Context.NOTIFICATION_SERVICE);
        // Notification note = new Notification(R.drawable.face,"NEW ACTIVITY", System.currentTimeMillis());
        Intent notificationIntent = new Intent(context, Alset.class);
        PendingIntent contentIntent = PendingIntent.getActivity(context,0, notificationIntent, 0);
        Notification notification = new Notification(icon, tickerText,when );
        //Notification notification1 = new Notification(R.drawable.icon, "Wake up alarm", System.currentTimeMillis());
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        notification.flags = Notification.FLAG_INSISTENT;
        notification.defaults |= Notification.DEFAULT_SOUND;
        //notification.setLatestEventInfo(context, "My Activity", "This will runs on button click", contentIntent);
        notofManager.notify(NOTIF_ID,notification);

        //PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
        //notification.setLatestEventInfo(context, "Context Title", "Context text", contentIntent);
        //notification.flags = Notification.FLAG_INSISTENT;
    }



}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

谢绝鈎搭 2024-11-24 14:20:36

我认为您想将闹钟设置为 6 月 26 日而不是 7 月 26 日。如果是这样,则将 cal.set(Calendar.MONTH,6); 更改为 cal.set(Calendar.MONTH,5); 因为月份是从零开始的。如果您打算在 7 月 26 日触发警报,则预计警报将在日期时间为 2011 年 7 月 26 日 17:30 时触发

I think you want to set the alarm for 26th June and not 26th July. If so then change cal.set(Calendar.MONTH,6); to cal.set(Calendar.MONTH,5); because the months are zero-based. if you intend the alarm to fire on 26th july then it is expected that the alarm will fire when the date-time is 26th July 2011, 17:30

空袭的梦i 2024-11-24 14:20:36

1.将其添加到清单文件中

 <receiver android:name=".MyAlarmReciever">
            <intent-filter>
                <action android:name="com.example.helloandroid.alarms" />
            </intent-filter>
        </receiver>        
  1. 创建一个活动

     public class AlrmActivity 扩展 BaseAcitivity {
    
            时间选择器 myTimePicker;
            按钮buttonstartSetDialog;
            TextView文本报警提示;
    
            TimePickerDialog timePickerDialog;
    
            最终静态 int RQS_1 = 1;
    
            @覆盖
            protected void onCreate(Bundle savingInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_alrm);
    
                textAlarmPrompt = (TextView)findViewById(R.id.alarmprompt);
    
                buttonstartSetDialog = (Button)findViewById(R.id.startSetDialog);
                buttonstartSetDialog.setOnClickListener(new View.OnClickListener(){
    
                    @覆盖
                    公共无效onClick(查看v){
                        textAlarmPrompt.setText("");
                        openTimePickerDialog(假);
    
                    }});
    
    
            }
    
            私有无效 openTimePickerDialog(boolean is24r){
                日历日历 = Calendar.getInstance();
    
                timePickerDialog = new TimePickerDialog(
                        AlrmActivity.this,
                        onTimeSetListener,
                        calendar.get(日历.HOUR_OF_DAY),
                        calendar.get(日历.分钟),
                        是24r);
                timePickerDialog.setTitle("设置闹钟时间");
    
                timePickerDialog.show();
    
            }
            TimePickerDialog.OnTimeSetListener onTimeSetListener
                    = new TimePickerDialog.OnTimeSetListener(){
    
                @覆盖
                公共无效onTimeSet(TimePicker视图,int hourOfDay,int分钟){
    
                    日历 calNow = Calendar.getInstance();
                    日历 calSet = (日历) calNow.clone();
    
                    calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    calSet.set(Calendar.MINUTE, 分钟);
                    calSet.set(日历.SECOND, 0);
                    calSet.set(Calendar.MILLISECOND, 0);
    
                    if(calSet.compareTo(calNow) <= 0){
                        //今天设定时间过去了,算到明天
                        calSet.add(日历.DATE, 1);
                    }
    
                    设置警报(calSet);
                }};
    
            私人无效setAlarm(日历targetCal){
    
                textAlarmPrompt.setText(
                        “\n\n***\n”
                                + "闹钟已设置@ " + targetCal.getTime() + "\n"
                                +“***\n”);
    
                Intent意图 = new Intent(getBaseContext(), MyAlarmReciever.class);
                PendingIntentendingIntent = PendingIntent.getBroadcast(getBaseContext(), RQS_1, 意图, 0);
                AlarmManager AlarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
                AlarmManager.set(AlarmManager.RTC_WAKEUP,targetCal.getTimeInMillis(),pendingIntent);
    
            }
    
        }
    

3 . xml文件包含

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="hello" />
        <Button
            android:id="@+id/startSetDialog"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Set Target Time"/>
        <TextView
            android:id="@+id/alarmprompt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

4个.make报警管理器类

    public class MyAlarmReciever extends BroadcastReceiver {

        Vibrator v;
        Context ct;
        String  title;


        @Override
        public void onReceive(Context context, Intent intent) {

            // TODO Auto-generated method stub
            ct=context;

            Log.e("onReceive", "ladskjflsakjdflskjdflskjdfslkjdflasdf");
            Toast.makeText(context, "OnReceive alarm test", Toast.LENGTH_SHORT).show();

            v=(Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
            v.vibrate(3000);

            int badgeCount = 1;
           // ShortcutBadger.applyCount(context, badgeCount);

            ShortcutBadger.removeCount(context);

            Bundle bundle = intent.getExtras();
            try{
                  title = intent.getExtras().get("title").toString();
                 // title = intent.getStringExtra("title");
                Toast.makeText(context, title, Toast.LENGTH_LONG).show();
            }catch(Exception e){
                e.printStackTrace();
            }


    //        if (!Utlis.checkNetworkConnection(context)) {
    //
    //            Notification(context, "Wifi Connection off");
    //
    //        } else {
                Notification(context, "Please  pray for this prayer ");

    //        }

        }


        public void Notification(Context context, String message) {
            // Set Notification Title
            String strtitle = "iPray  Prayer Reminder";
            // Open NotificationView Class on Notification Click
            Intent intent = new Intent(context, PrayerForOtherActivity.class);
            // Send data to NotificationView Class
            intent.putExtra("title", title);
            intent.putExtra("text", title);
            // Open NotificationView.java Activity
            PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);

    //        NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.app_icon, "Previous", pIntent).build();
            // Create Notification using NotificationCompat.Builder
            NotificationCompat.Builder builder = new NotificationCompat.Builder(
                    context)
                    // Set Icon
                    .setSmallIcon(R.drawable.app_icon)
                    // Set Ticker Message
                    .setTicker(message)
                    // Set Title
                    .setContentTitle(context.getString(R.string.app_name))
                    // Set Text
                    .setContentText(message)
                    // Add an Action Button below Notification
                    // Set PendingIntent into Notification
                    .setContentIntent(pIntent)
                    // Dismiss Notification
                    .setAutoCancel(true);

            // Create Notification Manager
            NotificationManager notificationmanager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            // Build Notification with Notification Manager
            notificationmanager.notify(38, builder.build());

        }
    }

1.add this in manifest file

 <receiver android:name=".MyAlarmReciever">
            <intent-filter>
                <action android:name="com.example.helloandroid.alarms" />
            </intent-filter>
        </receiver>        
  1. make a activity

         public class AlrmActivity extends BaseAcitivity {
    
            TimePicker myTimePicker;
            Button buttonstartSetDialog;
            TextView textAlarmPrompt;
    
            TimePickerDialog timePickerDialog;
    
            final static int RQS_1 = 1;
    
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_alrm);
    
                textAlarmPrompt = (TextView)findViewById(R.id.alarmprompt);
    
                buttonstartSetDialog = (Button)findViewById(R.id.startSetDialog);
                buttonstartSetDialog.setOnClickListener(new View.OnClickListener(){
    
                    @Override
                    public void onClick(View v) {
                        textAlarmPrompt.setText("");
                        openTimePickerDialog(false);
    
                    }});
    
    
            }
    
            private void openTimePickerDialog(boolean is24r){
                Calendar calendar = Calendar.getInstance();
    
                timePickerDialog = new TimePickerDialog(
                        AlrmActivity.this,
                        onTimeSetListener,
                        calendar.get(Calendar.HOUR_OF_DAY),
                        calendar.get(Calendar.MINUTE),
                        is24r);
                timePickerDialog.setTitle("Set Alarm Time");
    
                timePickerDialog.show();
    
            }
            TimePickerDialog.OnTimeSetListener onTimeSetListener
                    = new TimePickerDialog.OnTimeSetListener(){
    
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    
                    Calendar calNow = Calendar.getInstance();
                    Calendar calSet = (Calendar) calNow.clone();
    
                    calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    calSet.set(Calendar.MINUTE, minute);
                    calSet.set(Calendar.SECOND, 0);
                    calSet.set(Calendar.MILLISECOND, 0);
    
                    if(calSet.compareTo(calNow) <= 0){
                        //Today Set time passed, count to tomorrow
                        calSet.add(Calendar.DATE, 1);
                    }
    
                    setAlarm(calSet);
                }};
    
            private void setAlarm(Calendar targetCal){
    
                textAlarmPrompt.setText(
                        "\n\n***\n"
                                + "Alarm is set@ " + targetCal.getTime() + "\n"
                                + "***\n");
    
                Intent intent = new Intent(getBaseContext(), MyAlarmReciever.class);
                PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), RQS_1, intent, 0);
                AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
                alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
    
            }
    
        }
    

3 . xml file include

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="hello" />
        <Button
            android:id="@+id/startSetDialog"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Set Target Time"/>
        <TextView
            android:id="@+id/alarmprompt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

4 .make alarm manager class

    public class MyAlarmReciever extends BroadcastReceiver {

        Vibrator v;
        Context ct;
        String  title;


        @Override
        public void onReceive(Context context, Intent intent) {

            // TODO Auto-generated method stub
            ct=context;

            Log.e("onReceive", "ladskjflsakjdflskjdflskjdfslkjdflasdf");
            Toast.makeText(context, "OnReceive alarm test", Toast.LENGTH_SHORT).show();

            v=(Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
            v.vibrate(3000);

            int badgeCount = 1;
           // ShortcutBadger.applyCount(context, badgeCount);

            ShortcutBadger.removeCount(context);

            Bundle bundle = intent.getExtras();
            try{
                  title = intent.getExtras().get("title").toString();
                 // title = intent.getStringExtra("title");
                Toast.makeText(context, title, Toast.LENGTH_LONG).show();
            }catch(Exception e){
                e.printStackTrace();
            }


    //        if (!Utlis.checkNetworkConnection(context)) {
    //
    //            Notification(context, "Wifi Connection off");
    //
    //        } else {
                Notification(context, "Please  pray for this prayer ");

    //        }

        }


        public void Notification(Context context, String message) {
            // Set Notification Title
            String strtitle = "iPray  Prayer Reminder";
            // Open NotificationView Class on Notification Click
            Intent intent = new Intent(context, PrayerForOtherActivity.class);
            // Send data to NotificationView Class
            intent.putExtra("title", title);
            intent.putExtra("text", title);
            // Open NotificationView.java Activity
            PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);

    //        NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.app_icon, "Previous", pIntent).build();
            // Create Notification using NotificationCompat.Builder
            NotificationCompat.Builder builder = new NotificationCompat.Builder(
                    context)
                    // Set Icon
                    .setSmallIcon(R.drawable.app_icon)
                    // Set Ticker Message
                    .setTicker(message)
                    // Set Title
                    .setContentTitle(context.getString(R.string.app_name))
                    // Set Text
                    .setContentText(message)
                    // Add an Action Button below Notification
                    // Set PendingIntent into Notification
                    .setContentIntent(pIntent)
                    // Dismiss Notification
                    .setAutoCancel(true);

            // Create Notification Manager
            NotificationManager notificationmanager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            // Build Notification with Notification Manager
            notificationmanager.notify(38, builder.build());

        }
    }
咋地 2024-11-24 14:20:36

您是否在清单文件中设置了接收器?
像这样的东西

<receiver  android:process=":remote" android:name=".Mote"></receiver>

Have you set the receiver in your manifest file?
Something like this

<receiver  android:process=":remote" android:name=".Mote"></receiver>
执笔绘流年 2024-11-24 14:20:36

希望这会有所帮助

@Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                Calendar calNow = Calendar.getInstance();
                Calendar calSet = (Calendar) calNow.clone();

                calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
                calSet.set(Calendar.MINUTE, minute);
                calSet.set(Calendar.SECOND, 0);
                calSet.set(Calendar.MILLISECOND, 0);

                if(calSet.compareTo(calNow) <= 0){
                    //Today Set time passed, count to tomorrow
                    calSet.add(Calendar.DATE, 1);
                }

                setAlarm(calSet);
            }};

        private void setAlarm(Calendar targetCal){

            textAlarmPrompt.setText(
                    "\n\n***\n"
                    + "Alarm is set@ " + targetCal.getTime() + "\n"
                    + "***\n");

            Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
            PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), RQS_1, intent, 0);
            AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    //      alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
            alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent);
        }

hope this will help

@Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                Calendar calNow = Calendar.getInstance();
                Calendar calSet = (Calendar) calNow.clone();

                calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
                calSet.set(Calendar.MINUTE, minute);
                calSet.set(Calendar.SECOND, 0);
                calSet.set(Calendar.MILLISECOND, 0);

                if(calSet.compareTo(calNow) <= 0){
                    //Today Set time passed, count to tomorrow
                    calSet.add(Calendar.DATE, 1);
                }

                setAlarm(calSet);
            }};

        private void setAlarm(Calendar targetCal){

            textAlarmPrompt.setText(
                    "\n\n***\n"
                    + "Alarm is set@ " + targetCal.getTime() + "\n"
                    + "***\n");

            Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
            PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), RQS_1, intent, 0);
            AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    //      alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
            alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent);
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文