2013-02-17 2 views
0

알람을 설정하려고합니다. 나는 cvs 파일에 저장된 시간이있다. 형식은 hh : mm (예 : 02:13)입니다. 내가 어떻게이 날짜 형식에서 "시간"을 추출하고문자열 날짜를 알람으로 변환하십시오.

+0

'Date # getTime()'이 작동하지 않았습니까? –

+0

나는 diff 시간과 분으로 현재 날짜를 얻고 싶다. –

+0

현재 날짜의 시간과 분을 설정하고'getTime' 메소드를 사용할 수 있습니다. 또한 [joda-time] (http://joda-time.sf.net)을 사용하면 도움이 될 것입니다. –

답변

0

을 가지고 내 통지에 설정할 수 있습니다 내가 어려운 그것을 발견하고 다음 코드

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);   
    } 

을 사용하여이 시간

에 대한 알람을 설정하려면 이것을 시도했습니다 ....

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); 
관련 문제