본문 바로가기

옛글/안드로이드 프로그래밍

안드로이드의 여러가지 Intent(인텐트) !

반응형


// 웹페이지 띄우기

Uri uri = Uri.parse(Url주소);
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);

//이미지 갤러리

Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent,RESULT_IMAGEGALLERY);

//카메라 사진용

Intent intent = new Intent();
// intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
intent.setAction("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent,RESULT_TAKEPICTURE);

//동영상 갤러리

Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("video/*");

// Intent intent = new Intent(Intent.ACTION_PICK);
// intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.CONTENT_TYPE);
startActivityForResult(intent,RESULT_MOVIEGALLERY);

//카메라 동영상촬영용

Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra("android.intent.extra.sizeLimit", 972800L); //사이즈고정.. 촬영 시간을 고정시키는것도 있다. "android.intent.extra.durationLimit" 엿나?
startActivityForResult(intent,RESULT_TAKEMOVIE);

//주소록 호출

Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI );
startActivityForResult(intent,RESULT_CONTACTS);

//음성녹음

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent,RESULT_VOICERECORD);

//통화목록

Intent showCallLog = new Intent();

showCallLog.setAction(Intent.ACTION_VIEW);
showCallLog.setType(CallLog.Calls.CONTENT_TYPE);
startActivityForResult(showCallLog,OPTIONMENU_CALLLOG);

//파일 재생

Intent i = new Intent(android.content.Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File(여기에 FilePath..));
i.setDataAndType(uri,"audio/amr");
startActivity(i);

amr은 음성녹음파일이고 audio/* 하면 음악파일은 다 재생되는듯 하고 video/* 하면 동영상 파일 재생해준다.

//웹에 올려둔 파일 재생

Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(url주소),"audio/*");
startActivity(i);

반응형