IT개발일지/Android

[Android] 오늘하루 보지않기 팝업창 띄우기

삽질하는 개발자 봉이 2019. 1. 21. 17:57

안드로이드 개발을 하다 보면 "오늘 하루 보지 않기" 와 같은 알람 팝업을 제어 해야 할때가 있다.



AppUserData.setData(act,"date",strCurDate);


위와 같이 팝업창에서 x버튼을 눌렀을 경우 날짜를 담아 두고 


public void oneDayAppInfo(){
Intent intent;
if(StringUtil.isNull(AppUserData.getData(act,"date"))){
intent = new Intent(act, DlgAppInfo.class);
startActivity(intent);
}else{
String sDate = AppUserData.getData(act,"date");
SimpleDateFormat CurDateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = CurDateFormat.parse(sDate);
long now = System.currentTimeMillis();
Date today = new Date(now);
String strCurDate = CurDateFormat.format(today);
Date date2 = CurDateFormat.parse(strCurDate);
if(date2.after(date)){
//Log.d(CommonUtil.TAG,"날짜 : "+date2+"날짜 2 : "+date);
intent = new Intent(act,DlgAppInfo.class);
startActivity(intent);
}/*else{
Log.d(CommonUtil.TAG,"날짜 : "+date2+"날짜 2 : "+date);
}*/
} catch (ParseException e) {
e.printStackTrace();
}
}


아래 팝업을 띄우기 전 날짜를 비교해서 팝업창을 제어해준다


다른 방법이 있으시면 답글 달아주세요~!