레이블이 SIMPLE_안드로이드인 게시물을 표시합니다. 모든 게시물 표시
레이블이 SIMPLE_안드로이드인 게시물을 표시합니다. 모든 게시물 표시

2017년 2월 16일 목요일

안드로이드 스튜디오 apk 배포시 multiDexEnabled 오류


안드로이드 스튜디오 apk 배포시 multiDexEnabled  오류

android {

    defaultConfig {
        ...

        // Enabling multidex support.
        multiDexEnabled = true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}


안드로이드 스튜디오 빌드 속도 향상 시키는 방법


안드로이드 스튜디오 빌드 속도 향상 시키는 방법

안드로이드 스튜디오 빌드 속도 향상 시키기 

프로젝트의 루트에 gradle.properties를 생성하고 안드로이드 스튜디오를 재실행하면 반영이 돼요
마지막 라인이 중요해요
project.android.dexOptions.preDexLibraries = false
빌드서버에서 빌드를 하는 경우에는 기존 빌드된 결과물을 재활용하는 대신 항상 클린 빌드를 수행할 필요가 없어요, 따라서 그래들 증분 빌드의 효과를 누릴 수가 없어요, 하지만, 기본적으로 그래들 안드로이드 플로그인은 증분 빌드 기능을 최적화 하기 위하여 최초 빌드시 모든 서브 모듈들을 pre-dexing 하는 작업을 수행해요, 다만, 이런 경우 첫 번째 빌드 시에는 더 오랜 시간이 걸리게 되며 빌드 서버에서는 별로 적절하지 않은 작업이 된다, 따라서 안드로이드 그래들 플러그인의 preDexLibraries 속성을 사용하지 않도록 위와 같이 사용하는 것이 좋아요
# Project-wide Gradle settings.# IDE (eg Android Studio) users :# Settings specified in this file will override any Gradle settings# configured through the IDE.# For more details on  how to configure your build environment visit# http : // www.gradle.org/docs/current/userguide/build_environment.html# The Gradle daemon aims to improve the startup and execution time of Gradle.# When set to true the Gradle daemon is to run the build.# TODO : disable daemon on  CI, Since Builds should BE clean and Reliable on  serversorg.gradle.daemon = true
# Specifies the JVM arguments used for the daemon process.# The setting is particularly useful for tweaking memory settings.# Default value : -Xmx10248m -XX : MaxPermSize = 256Morg.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.# This option should on ly be used with decoupled projects. More details, visit# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec : decoupled_projectsorg.gradle.parallel = true
# Enables new incubating mode that makes Gradle selective when configuring projects.# on ly relevant projects are configured which results in faster builds for large multi-projects.# http://www.gradle.org/docs/current/userguide/multi_project_builds.html #sec : configuration_on_demandorg.gradle.configureondemand = true
project.android.dexOptions.preDexLibraries = false



안드로이드 sms 읽기 (read sms) method


안드로이드 sms 읽기 (read sms) method 

androidManifest.xml에서의 퍼미션 설정 
<uses-permission android:name="android.permission.READ_SMS" />

/*
 * 문자 read 
 */
public synchronized int readSMSMessage() {
  Uri allMessage = Uri.parse("content://sms");
  ContentResolver cr = actMain.getContentResolver();
  Cursor c = cr.query(allMessage, 
 new String[] { "_id", "thread_id", "address", "person", "date", "body", "read" },
 null, null, 
 "date DESC");
   
  String string ="";
  int count=0;
  while  (c.moveToNext()) { 
  long messageId = c.getLong(0); 
  long threadId = c.getLong(1); 
  String address = c.getString(2); 
  long contactId = c.getLong(3); 
  String contactId_string = String.valueOf(contactId); 
  long timestamp = c.getLong(4); 
  String body = c.getString(5);
  long read     = c.getLong(6);
  
  if(read==0 && body.indexOf("인증번호")>-1){
 string = String.format("msgid:%d, threadid:%d, address:%s, " +
 "contactid:%d, contackstring:%s, timestamp:%d, body:%s", 
 messageId, threadId, address,
 contactId, contactId_string, timestamp, body);
 Log.d("maluchi", ++count +"st, Message: "+string);
 
 actMain.alertCommonMsg("읽지 않은 문서 : "+string);
  }
  }
  
  return 0;
 }

읽지 않은 문서중에 인증번호라는 텍스트가 있는것을 불러들여서 alert창으로 출력해줘요 




안드로이드 스튜디오 import org.apache.http* 에러 해결 방법


안드로이드 스튜디오 import org.apache.http* 에러 해결 방법

안드로이드 스튜디오 import org.apache.http* 에러 해결 방법


build.gradle에서 다음소스 추가

dependencies {
    //.....
    provided 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}

have a nice day~


2016년 3월 24일 목요일

바코드스캐너#안드로이드 해상도와 무관하게 스캔영역 넓히기



바코드스캐너
#안드로이드 해상도와 무관하게 스캔영역 넓히기



소스)

CameraManager.java

/**
   * Calculates the framing rect which the UI should draw to show the user where to place the
   * barcode. This target helps with alignment as well as forces the user to hold the device
   * far enough away to ensure the image will be in focus.
   *
   * @return The rectangle to draw on screen in window coordinates.
   */
  public synchronized Rect getFramingRect() {
  if (framingRect == null) {
      if (camera == null) {
        return null;
      }
      Point screenResolution = configManager.getScreenResolution();
      int width = screenResolution.x * 3 / 4;
 
      int height = screenResolution.y * 3 / 4;
      Log.v("Framing rect is : ", "width is "+width+"   and height is "+height);
      int leftOffset = (screenResolution.x - width) / 2;
      int topOffset = (screenResolution.y - height) / 2;
      framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
      Log.d(TAG, "Calculated framing rect: " + framingRect);
  }
  return framingRect;

  /*if (framingRect == null) {
      if (camera == null) {
        return null;
      }
      Point screenResolution = configManager.getScreenResolution();
      if (screenResolution == null) {
        // Called early, before init even finished
        return null;
      }
      int width = findDesiredDimensionInRange(screenResolution.x, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
      int height = findDesiredDimensionInRange(screenResolution.y, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
      int leftOffset = (screenResolution.x - width) / 2;
      int topOffset = (screenResolution.y - height) / 2;
      framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
      Log.d(TAG, "Calculated framing rect: " + framingRect);
      }
      return framingRect;*/
  }

* 해상도와 무관하게 스캔의 영역을 넓혀줘요

==========================================

소스) 캡춰 화면



* 안드로이드 어플중에 대만에서 만든 바코드 스캐너, 큐알스캐너 어플이 있는데, 아주 심플하지만  인기가 좋은  이유가 있었다,
지인중에 기획력이 뛰어난 분이 면밀히 검토한 결과 발견했는데, 미묘한 차이점 중 하나가 스캔영역을 넓혀주니 스캔이 잘되게 해주는 편리함을 제공해주니 인기가 좋다,,,
이외에  간단하면서도 군더더기가 없었던게 인기의 비결이었다고 해요

- 안드로이드 어플 개발하는데 있어서의 핵심 포인트는 편리함과 안정성

즐거운 시간 보내세요~

2016년 3월 4일 금요일

바코드스캐너#back button 클릭시의 이벤트 처리, dispatchKeyEvent


바코드스캐너
#back button 클릭시의 이벤트 처리, dispatchKeyEvent



대부분의 어플이 onKeyDown 이벤트가 동작을 잘하지만 zxing을 활용은 어플은 back button click 되었을 시 사이트의 사운드 키나 메뉴키가 터치된 경우에 동작을 하지만 취소 키가 터치된 경우에는 반응을 하지 않는다, 이 경우 해결 방법이 구글링을 해보니 방법이 나와 있다, dispatchKeyEvent가 바코드스캐너 어플에서 동작이 가능하게 해준다
barcode scanner에서 종료시 광고를 띄우거나 리뷰로 유도하기 위하여 back button 터치이벤트를 활용하는데, 이 dispatchKeyEvent를 활용해서 개발하시면 유용해요

소스)
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
      
      switch (event.getKeyCode()) {
      case KeyEvent.KEYCODE_BACK:
    
      finish();
        break;
      case KeyEvent.KEYCODE_FOCUS:
      case KeyEvent.KEYCODE_CAMERA:
        return true;
      case KeyEvent.KEYCODE_VOLUME_DOWN:
       execFlash();
       return true;
      case KeyEvent.KEYCODE_VOLUME_UP:
       execFlash();
       return true;
  }
      
      return true;
  }

소스) 이미지


방문해주셔서 감사해요
즐거운 시간 보내세요~

2016년 3월 3일 목요일

바코드스캐너#다국어버전 개발에 필요한 R.string을 String으로 변환하기


바코드스캐너

#다국어버전 개발에 필요한 R.string을 String으로 변환하기



다국어버전 어플을 만들 경우에도 사용돼요


자바소스
String sUnitUpdateInfo = getResources().getString(R.string.update_info);
String sUnitRateReview = getResources().getString(R.string.rate_review);
String sUnitCreateQr = getResources().getString(R.string.create_qr);

...

xml 파일 (strings.xml)

<string name="update_info">Update</string>
<string name="rate_review">Rate and Review</string>
<string name="create_qr">Create QR</string>


values/strings.xml
values-ko/strings.xml
...


즐거운 시간 보내세요~