본문 바로가기

Programming/Android

[Android] Handler & Looper [Handler & Looper] android.os.Looper오직 한개만 있는 메시지 발송자 android.os.Message데이터나 태스크 두가지 중 하나만 옮기는 컨테이너 객체 데이터 메시지 태스크 메시지 여러 개의 매개변수를 담는 메시지(what, [arg1, arg2], obj, data, replyTo, callback) java.lang.Runnable만 포함하고 데이터는 포함하지 않는다. android.os.MessageQueue처리할 메시지들이 담긴 무제한의 연결 리스트. 모든 루퍼와 스레드는 최대 하나의 메시지 큐를 가짐. android.os.Handler큐에 메시지를 삽입 & 메시지 처리 >> 관계도 출처 : Efficient Android Threading(출판사 : 한빛미디어) 더보기
[Android] Google Play Store로 이동시키기 Google Play Store로 이동시키기앱 리뷰 남기기 위한 유도 팝업(MaterialDialog 사용)app/build.grade dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile('com.github.afollestad.material-dialogs:commons:0.8.5.5@aar') { transitive = true } ...} Source public void goPlayStore(String content, String positiveText, String negativeText) { new MaterialDialog.Builder(ReviewActiv.. 더보기
[Android] 선택 되었을 때 Text Color 바꾸기 Change Select Text Color(TextView, Button).md Change Select Text Color(TextView, Button)drawable를 만들지 않고 select text color 변경하기(Util)TextView나 Button에서 press나 select 되었을 때, text color를 바꾸려면 아래와 같이 drawable에 selector를 만들어 줘야한다. 그리고 여러 색을 사용할 경우 사용할 때마다 selector를 만들어 줘야한다. xxxxxxxxxx6123 4 5 6그래서, 코드에서 함수로 만들었습니다.(Util같은 곳에 추가해서 사용하시면 될 것 같습니다.)(단, Button과 TextView만 해놓았습니다. 추가하시려면 if문 조건대로 추가하시면 됩.. 더보기
[Android] Square ImageView (정사각형 ImageView) Square ImageView(Custom) → 프로필 사진이나 기타 사진등을 정사각형으로 보여주기 위해 만들게 됨(특히 LinearLayout에서 비율로 보여줄때) Source Code → 기준(mFit)을 입력 받아 onMeasure함수에서 기준에 따라 크기를 정함. 1) SquareImageView.javaimport android.content.Context; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.AttributeSet; public class SquareImageView extends android.support.v7.widget.AppCompatImageView .. 더보기
[Android] Spannable [ Spannable ] : TextView를 여러 개 쓰지 않아도 하나의 TextView에서 해당 text를 부분적으로 바꿀 수 있다. SpnnableUtils.javaimport android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.AbsoluteSizeSpan; import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; /** * Created by gpark on 2017-01-31. */ public class SpannableUtils { /** * @param text : 적용.. 더보기
[Android] GPS 설정 체크하기 [ Android GPS Check ] public boolean checkGPSService() { LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { // GPS OFF 일때 Dialog 표시 new MaterialDialog.Builder(this) .title("위치 서비스 설정") .content("위치 서비스 기능(GPS)을 설정해주세요.") .positiveText("확인") .onPositive(new MaterialDialog.SingleButtonCallback() { .. 더보기
[Android] Volley & Patch request [ Android Patch request ] 1. HttpPost의 Header에 X-HTTP-Method-Override 추가 httpost.setHeader("X-HTTP-Method-Override", "PATCH"); 2. 위 1번 방법이 되지 않을 경우 okHttp 활용(Android Studio 기준) I) build.gradle에 library 추가 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) ... compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0' } II) CustomHttpStack .. 더보기
[Android] Activity Life Cycle(생명주기) ⊙ Activity Life Cycle (액티비티 생명주기) : Activity에는 Life Cycle이 존재한다. Life Cycle은 아래 그림과 같다. * 각 함수들의 설명 Method Description Killable? Next onCreate() Activity가 처음 만들어질 때 호출되는 함수. 보통 create view, bind data to list 등을 onCreate()에서 한다. 그리고 이전 상태를 포함한 Bundle을 제공한다. No onStart() onRestart() Activity가 다시 시작되기 전에 Activity가 멈춘 후 호출되는 함수. No onStart() onStart() Activity가 User에게 보여질 때 호출되는 함수. No onResume() or.. 더보기
[Android] 외부 앱 실행 [Android] 외부 앱 실행 앱 정보 얻어오기 12345678910Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); // package Infomation PackageManager pm = getPackageManager(); // 설치되어 있는 App 정보 List installedApps = pm.queryIntentActivities(intent, 0); for(ResolveInfo app : installedApp) { Log.i("App Info : ", app.activityInfo.packageName); } 외부 앱 실행시키기 실행시킬 앱의 Activity Name까지.. 더보기
[Android] Android Soft KeyBoard Show and Hide [Android] Android Soft KeyBoard Show and Hide Android 키보드 보이기 12345private void showKeyBoard() { EditText editText = ...; InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInputFromInputMethod (editText.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED); } Android 키보드 감추기 12345private void hideKeyBoard() { EditText editText = ...;.. 더보기