2012. 7. 10. 22:36
안드로이드 - 동영상 촬영 후 Uri 가져오기 안드로이드 이야기2012. 7. 10. 22:36
728x90
반응형
[android] 동영상 촬영 후 Uri 가져오기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 |
// 동영상 촬영 private void doCaptureVideo() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, CAPTURE_MOVIE); } @Override public void onActivityResult( int requestCode, int resultCode, Intent intent) {
super .onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK)
{
if (requestCode == CAPTURE_MOVIE)
{
Uri uri = intent.getData();
String path = getPath(uri);
String name = getName(uri);
String uriId = getUriId(uri);
Log.e( "###" , "실제경로 : " + path + "\n파일명 : " + name + "\nuri : " + uri.toString() + "\nuri id : " + uriId);
}
} } // 실제 경로 찾기 private String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null , null , null );
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index); } // 파일명 찾기 private String getName(Uri uri) {
String[] projection = { MediaStore.Images.ImageColumns.DISPLAY_NAME };
Cursor cursor = managedQuery(uri, projection, null , null , null );
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DISPLAY_NAME);
cursor.moveToFirst();
return cursor.getString(column_index); } // uri 아이디 찾기 private String getUriId(Uri uri) {
String[] projection = { MediaStore.Images.ImageColumns._ID };
Cursor cursor = managedQuery(uri, projection, null , null , null );
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns._ID);
cursor.moveToFirst();
return cursor.getString(column_index); } |
728x90
반응형
'안드로이드 이야기' 카테고리의 다른 글
안드로이드 - 터치로 그리기 (0) | 2012.07.10 |
---|---|
안드로이드 - 카메라로 사진찍어 이미지 가져오기 (0) | 2012.07.10 |
안드로이드 - 촬영한 이미지를 getFilesDir()에도 저장하기 (0) | 2012.07.10 |
안드로이드 - 알람시 화면깨우기 (0) | 2012.06.25 |
안드로이드 - 문자열중 단어검색 (0) | 2012.06.09 |