第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

字符串的date轉(zhuǎn)換為alarm

字符串的date轉(zhuǎn)換為alarm

不負相思意 2019-03-21 18:15:16
我想設(shè)置alarms 功能,我把時間存儲在一個cvs文件中。格式是hh:mm,如02:13。我想在這個時間點設(shè)置鬧鐘。 SimpleDateFormat  dt = new SimpleDateFormat("hh:mm");        dt.parse(str); // GET TIME HERE NotificationManager manger = (NotificationManager) this.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);         Notification notification = new Notification(R.drawable.launcher, "Mosque Prayer Times", time);         PendingIntent contentIntent = PendingIntent.getActivity(this.getActivity(), 0, new Intent(this.getActivity(),          AlarmReceiver.class), 0);         notification.setLatestEventInfo(this.getActivity(), name, title, contentIntent);         notification.flags = Notification.FLAG_INSISTENT;         notification.sound = Uri.parse("android.resource://com.trib.app.mosqueprayertimes/raw/adhan.mp3");         manger.notify(id, notification);             }我如何從date 格式中提取時間然后在通知中設(shè)置?
查看完整描述

2 回答

?
守候你守候我

TA貢獻1802條經(jīng)驗 獲得超10個贊

AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); 
  SimpleDateFormat  dt = new SimpleDateFormat("hh:mm"); 
  Date date = new Date();  //當前時間日期
     try {
                 Date dateTime = dt.parse(str);
         date.setHours(dateTime.getHours());
             date.setMinutes(dateTime.getMinutes());

     } catch (ParseException e) {
            e.printStackTrace();
    }         
 am.set(AlarmManager.RTC_WAKEUP,date.getTime(), contentIntent);


查看完整回答
反對 回復(fù) 2019-04-29
?
慕慕森

TA貢獻1856條經(jīng)驗 獲得超17個贊

試一下:

SimpleDateFormat  dt = new SimpleDateFormat("hh:mm"); 
     Date date=  dt.parse(str); // GET TIME HERE
    Calender cal=Calender.getInstance();
    cal.setTime(date);
    String hours=cal.get(Calendar.HOUR);
    String minutes=cal.get(Calendar.MINUTE);


查看完整回答
反對 回復(fù) 2019-04-29
  • 2 回答
  • 0 關(guān)注
  • 477 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號