안드로이드의 인텐트 기능을 활용하여서 T Map의 특정 기능으로 바로 가기를 사용 할 수 있습니다. 또한 Tasker 등의 앱을 활용하게 된다면 더욱 스마트하게 사용 할 수 있습니다. 검색 (T Map 외 다른 지도 앱에서도 사용 가능)
1 | geo:0.0?q=검색어 |
안전운전
1 | tmap://ando |
주변
1 | tmap://nearby |
운전습관
1 | tmap://driving-habit |
언제갈까
1 | tmap://schedule |
안드로이드의 인텐트 기능을 활용하여서 T Map의 특정 기능으로 바로 가기를 사용 할 수 있습니다. 또한 Tasker 등의 앱을 활용하게 된다면 더욱 스마트하게 사용 할 수 있습니다. 검색 (T Map 외 다른 지도 앱에서도 사용 가능)
1 | geo:0.0?q=검색어 |
안전운전
1 | tmap://ando |
주변
1 | tmap://nearby |
운전습관
1 | tmap://driving-habit |
언제갈까
1 | tmap://schedule |
개발을 하다보면 사진을 가져오거나 사진 찍기, 이미지 크롭 기능이 필요한 경우가 있습니다. 하지만 이런 기능들을 필요할 때마다 개발을 한다는 건 비효율 적이죠. 그래서 안드로이드는 Intent를 통하여 외부 앱을 적절히 활용 할 수 있도록 도와 줍니다. 사진 가져오기
1 2 3 4 5 6 7 | private void dispatchPickPictureIntent() { Intent pickPictureIntent = new Intent(Intent.ACTION_GET_CONTENT); pickPictureIntent.setType("image/*"); if (pickPictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(pickPictureIntent, REQUEST_IMAGE_PICK); } } |
사진 찍기
1 2 3 4 5 6 7 8 | private void dispatchTakePictureIntent() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "edp_image.jpg")); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUri); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } } |
사진 크롭
1 2 3 4 5 6 7 8 9 10 11 12 13 | private void dispatchCropPictureIntent(Uri uri) { Intent cropPictureIntent = new Intent("com.android.camera.action.CROP"); cropPictureIntent.setDataAndType(uri, "image/*"); cropPictureIntent.putExtra("outputX", 640); // crop한 이미지의 x축 크기 (integer) cropPictureIntent.putExtra("outputY", 480); // crop한 이미지의 y축 크기 (integer) cropPictureIntent.putExtra("aspectX", 4); // crop 박스의 x축 비율 (integer) cropPictureIntent.putExtra("aspectY", 3); // crop 박스의 y축 비율 (integer) cropPictureIntent.putExtra("scale", true); cropPictureIntent.putExtra("return-data", true); if (cropPictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(cropPictureIntent, REQUEST_IMAGE_CROP); } } |
결과 처리
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { switch (requestCode) { case REQUEST_IMAGE_PICK: // dispatchPickPictureIntent() 결과 dispatchCropPictureIntent(data.getData()); break; case REQUEST_IMAGE_CAPTURE: // dispatchTakePictureIntent() 결과 dispatchCropPictureIntent(mUri); break; case REQUEST_IMAGE_CROP: // dispatchCropPictureIntent() 결과 Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); mThumbnail.setImageBitmap(ditherBitmap); break; } } } |
어플리케이션을 개발하다보면 외부 어플리케이션의 실행을 원할 때가 있는데 이 경우 보통 묵시적 호출을 통해서 외부 어플리케이션을 실행 시킵니다. 하지만 간혹 명시적으로 필요한 어플리케이션을 딱 지정해서 실행을 시키고 싶을 때가 있습니다. 이럴 경우 아래와 같이 패키지명과 액티비티명으로 명시적으로 호출을 할 수 있습니다. ComponentName cn = new ComponentName(”패키지명”, 패키지명.액티비티명”); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); […]
개발하고 있는 패키지 안에 있는 어플이 아닌 기기에 따로 설치되어 있는 어플을 설치하기 위해서는 해당 어플의 패키지와 액티비티를 알아야 한다.
1 2 3 4 5 | ComponentName compName = new ComponentName("com.package", "com.package.activity"); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(compName); startActivity(intent); |