본문 바로가기

About Programing/05. Android

Android에서 수동으로 MediaScan 하기 sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); 더보기
Android에서 기기 계정 정보 가져오기 AndroidManifest.xml 에서 Permission 설정 Source Account[] accounts = AccountManager.get(this).getAccounts(); 더보기
Android 내장 메모리의 사진 정보 가져오기 AndroidManifest.xml 에서 Permission 설정 Main.java package com.eg.giver; import java.util.ArrayList; import android.app.Activity; import android.database.Cursor; import android.os.Bundle; import android.provider.MediaStore.Images; public class Main extends Activity { ArrayList mTitleArray; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(.. 더보기
Android 내장 Calendar에서 일정 읽어 오기 Google Calendar와 동기화 하는 방법을 찾다가 Java에서는 쉽게 구현 가능하지만, Android와 Google Calendar API가 궁합이 맞지 않다는 것을 알고 우회하기로 하였다. 어차피 내장 Calendar는 Google Calendar와 자동으로 동기화가 되니, 내장 Calendar에서 값을 읽어 오기로 하였다. // Main.java package com.calendar; import java.util.ArrayList; import java.util.List; import android.app.ListActivity; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import an.. 더보기
Android EditText의 InputType 설정값 main.xml 속성에서 android:inputType= 으로 설정 가능. 양수 : number / 숫자 : numberSigned / 소수점 : numberDecimal "|" 연산자를 통해 두가지 속성을 같이 적용할 수 있음. (number|numberDecimal) 속성값 android:inputType Since: API Level The type of data being placed in a text field, used to help an input method decide how to let the user enter text. The constants here correspond to those defined byInputType. Generally you can select a sing.. 더보기
Android Service에서 Activity 실행하기 Context context = getApplicationContext(); Intent intent = new Intent(context, Action.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); 더보기
Android에서 URI로 실제 파일 경로 가져오기 /** * URI로 부터 실제 파일 경로를 가져온다. * @param uriPath URI : URI 경로 * @return String : 실제 파일 경로 */ public String getRealImagePath (Uri uriPath) { String []proj = {MediaStore.Images.Media.DATA}; Cursor cursor = managedQuery (uriPath, proj, null, null, null); int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String path = cursor.getString(index); path = path.sub.. 더보기
Activity Class나 View Class를 상속 받지 않는 Class의 startActivity() 함수 호출 애니메이션이 들어가는 Menu 화면을 그린다고 Surface Class 를 상속받아서 생성한 클래스 안에서 startActivity 함수를 부르니 에러가 나왔다. " the method startActivity(Intent) is undefined for the type " 이럴때는 getContext().startActivity(intent); 로 써보자. 그러면 startActivity 함수를 사용할 수 있다. 더보기
Activity 생명 주기 더보기
onTouchEvent @Override public boolean onTouchEvent(MotionEvent event, MapView mapView) { // Touch 한 곳의 X 좌표 double xPoint = (double)event.getX(); // Touch 한 곳의 Y 좌표 double yPoint = (double)event.getY(); // Touch Action 값 int actionValue = event.getAction(); switch (actionValue) { // Touch 했을 때 case MotionEvent.ACTION_DOWN : break; // Touch 땟을 때 case MotionEvent.ACTION_UP : break; // Drag case MotionEvent.ACT.. 더보기