public void registerInit() { SharedInit SI = new SharedInit(context); AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE); Intent intentMyService; PendingIntent sender; intentMyService = new Intent("ACTION.GET.ONE"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("0"), sender); intentMyService = new Intent("ACTION.GET.TWO"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("1"), sender); intentMyService = new Intent("ACTION.GET.THREE"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("2"), sender); intentMyService = new Intent("ACTION.GET.FOUR"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("3"), sender); intentMyService = new Intent("ACTION.GET.FIVE"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("4"), sender); intentMyService = new Intent("ACTION.GET.SIX"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("5"), sender); intentMyService = new Intent("ACTION.GET.SEVEN"); sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); am.set(AlarmManager.RTC, SI.getSharedTime("6"), sender); }
public void registerAM(String idIndex, String index) { SharedInit SI = new SharedInit(context); try { SI.setSharedTimeLong(index, SI.getSharedTime(index)); Intent intentMyService; intentMyService = new Intent(idIndex); AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE); PendingIntent sender = PendingIntent.getBroadcast(context, 0, intentMyService, 0); // 서비스 시작 am.set(AlarmManager.RTC, SI.getSharedTime(index), sender); } catch (Exception e) { Log.d("MpMainActivity", e.getMessage() + ""); e.printStackTrace(); } }
public void TimeChecked(View v) { String timestr = ""; SharedInit si = new SharedInit(MainActivity.mContext); Long tt = si.getSharedTime("0"); DateFormat df = new SimpleDateFormat("HH:mm:ss"); String str = df.format(tt); String[] click_str = str.split(":"); timestr += "아침 - " + click_str[0] + ":" + click_str[1] + "\n"; tt = si.getSharedTime("1"); df = new SimpleDateFormat("HH:mm:ss"); str = df.format(tt); click_str = str.split(":"); timestr += "아점 - " + click_str[0] + ":" + click_str[1] + "\n"; tt = si.getSharedTime("2"); df = new SimpleDateFormat("HH:mm:ss"); str = df.format(tt); click_str = str.split(":"); timestr += "점심 - " + click_str[0] + ":" + click_str[1] + "\n"; tt = si.getSharedTime("3"); df = new SimpleDateFormat("HH:mm:ss"); str = df.format(tt); click_str = str.split(":"); timestr += "점저 - " + click_str[0] + ":" + click_str[1] + "\n"; tt = si.getSharedTime("4"); df = new SimpleDateFormat("HH:mm:ss"); str = df.format(tt); click_str = str.split(":"); timestr += "저녁 - " + click_str[0] + ":" + click_str[1] + "\n"; tt = si.getSharedTime("5"); df = new SimpleDateFormat("HH:mm:ss"); str = df.format(tt); click_str = str.split(":"); timestr += "야식 - " + click_str[0] + ":" + click_str[1] + "\n"; tt = si.getSharedTime("6"); df = new SimpleDateFormat("HH:mm:ss"); str = df.format(tt); click_str = str.split(":"); timestr += "후식 - " + click_str[0] + ":" + click_str[1]; tv.setText(timestr); }