인기글
-
[Java] Calendar(캘린더) 해당 월 마지막 날짜 구하기
java.util.Calendar의 해당 월의 마지막 날짜(일)를 가져오기 1 2 3 4 Calendar calendar= Calendar.getInstance(); calendar.add(Calendar.MONTH, 8); // 9월 세팅 (월 세팅은 0~11이기에..) int dayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); // 마지막 날짜 반환 (2018년 9월 30일) calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); // Day를 마지막날짜(30일)로 세팅 cs
2018.09.17 15:26 -
Android 홈바로가기(Shortcut) 생성
홈바로가기 생성은 아래 코드 참고 사용법 1 2 3 4 5 6 String name = 바로가기의 이름 설정 int flag = 바로가기 실행 시 구분하기 위한 값 (필수가 아니므로 없어도 무방) int resId = 바로가기 아이콘 설정 addShortcut(name, flag, resId); cs 관련 코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 private static final String ACTION_INSTALL_SHORTCUT = "..
2018.09.17 17:07 -
Android APP 재시작 방지
Notification, 홈바로가기에서 앱을 실행 하게 될 경우 앱이 실행되어 있는 상태(홈버튼으로 내린 상태 포함)에서도 재시작이 되는데재시작을 하고 싶지 않은 경우 아래의 코드를 참고하시면 될거 같습니다. Intent를 아래와 같이 정의할 경우 앱이 실행되어 있을 시 화면이 유지(홈버튼으로 내린 상태인 경우 마지막화면에서 Foreground가 됨)되며 그렇지 않은 경우 처음부터 실행이 됩니다. 다른방법도 많이 있겠지만 필자의 경우 이 방법을 통해 해결하였기에 적어봅니다. 1234Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_LAUNCHER);intent.setClass(context, StartActi..
2018.09.17 16:35 -
android App 알림 허용 상태 값 가져오기
디바이스 설정 > 애플리케이션 > 해당 앱 정보 > 알림 > "알림 허용(On/Off)" 상태를 알 수 있는 API 1NotificationManagerCompat.from(context).areNotificationsEnabled();cs
2018.02.20 13:36 -
Android SpannableStringBuilder BulletSpan Custom (ImageBulletSpan)
BulletSpan은 아래처럼 텍스트에 글머리 기호를 넣는 기능이다.하지만 글머리 기호는 변경할 수가 없다. 그래서 필자는 글머리 기호를 이미지로 표현하는 BulletSpan을 만들어보았다. 먼저 LeadingMarginSpan을 implements한 클래스를 하나 생성하고아래와 같이 getLeadingMargin(), drawLeadingMargin()을 오버라이드한다. 1234567891011121314public class ImageBulletSpan implements LeadingMarginSpan { @Override public int getLeadingMargin(boolean first) { return 0; } @Override public void drawLeadingMargin(Ca..
2016.12.06 13:39