본문 바로가기

IT개발일지

(63)
[Android] 다운로드 URL을 이용하여 파일 다운로드하기 public File fileEmptyPDF(final String downloadURL) { final File resultFile = new File(Cvalue._DOWNLOAD_FOLDER, downloadURL.substring(downloadURL.lastIndexOf("/") + 1).replace(".pdf", "_edit.pdf")); try { resultFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } Thread thread = new Thread() { public void run() { FileDownloader.downloadFile(downloadURL, resultFile); } }; thread...
[Android] PDF 파일 합치기 merge public static File getMergePDF(ArrayList fileList, String wantFileName, final Activity act) { final File outputFile = new File(Cvalue._DOWNLOAD_FOLDER + "/" + wantFileName); // Log.d(CommonUtil.TAG, "outputFile1 > " + outputFile.getAbsolutePath() + " / " + outputFile.length()); try { List pdfs = new ArrayList(); for (int i = 0; i < fileList.size(); i++) { pdfs.add(new FileInputStream(fileList.ge..
[Android] 안드로이드 PDF 파일 열기 try { Intent i = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Uri contentUri = FileProvider.getUriForFile(act, "패키지명", printFile(File)); i.setDataAndType(contentUri, "application/pdf"); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else { i.setDat..
[Android] PrintHelper 안드로이드 wifi 프린트로 출력하기 안드로이드 어플리케이션 개발중 프린트 출력하기 기능을 알아보았다. 크게 2가지로 나뉘는데 1. 구글 클라우드 프린트이용 2. 안드로이드자체제 공해주는 printhelper 를 이용하는 것이다. 오늘은 후자에 대해 메모를 하려고 한다. 나는 pdf 파일을 출력하는 방식으로 코딩을 하였다. public void doPhotoPrint(String filePath){ PrintManager printManager = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { printManager = (PrintManager) this.getSystemService(Context.PRINT_SERVICE); Str..
[Android] Glide 이용하여 RGB 색상채우기 Android 개발 시 아래와 같은 동그란 이미지에 RGB 색상 값만 채우고 싶을 때가 있다. 해결 방법 try{ GradientDrawable bgShape = (GradientDrawable) colorView[i].getBackground(); bgShape.setColor(Color.parseColor("#RGB색상값"); }catch(Exception e){ GradientDrawable bgShape = (GradientDrawable) colorView[i].getBackground(); bgShape.setColor(Color.parseColor("#FFFFFF")); } 위와 같이 Glide를 사용 하여 RGB색상값을 입력해주었다. ※ 원모양은 drawable xml을 선언 해주어서 만들..
[Android] Broadcast 휴대폰 부팅 프로세스 어플리케이션을 개발하다 보면 휴대폰 부팅시에 작업해야할 사항들이 생긴다. 그럴때 사용하는게 Broadcast . 해결방법 1. Manifest 에 service를 등록 해줍니다. 2. BroadcastReceiver를 상속 받아서 부팅 액션으로 제어하기. public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent){ String action = intent.getAction(); if(action.equalsIgnoreCase("android.intent.action.BOOT_COMPLETED")){ //부팅시 시작할 작업 작성 } } } } 다른 좋은 방..
[Android] notification 중복 알림 방지 안드로이드 어플리케이션을 개발 하다 보면 Notification 알림을 사용하는 경우가 많다. 예를 들어 FCM 푸쉬를 사용할 때 자주 발생할 수 있는 이슈이다. 해결방법Notification Build 적용시 id 값을 다른 값으로 적용 시켜준다 위와 같은 방법으로 Notification 알림을 받은 시간을 기준으로 id 값을 적용 시켜주었다. 위와 같은 방법을 이용하면 푸쉬가 오더라도 다른 푸쉬로 인식하여 중복으로 겹치는 현상을 방지할수 있다. 다른 방법이 있으신 분들은 댓글로 공유하여 주시면 감사하겠습니다~!