@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final String items[] = {"갤러리에서 가져오기","카메라로 촬영하기"};
if (url.startsWith("custom://")) {
new AlertDialog.Builder(MyPageWeb.this)
.setIcon(R.drawable.icon)
.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), Integer.toString(item), Toast.LENGTH_SHORT).show();
dialog.dismiss();
if(item==0) {
//갤러리 호출
Uri uri = Uri.parse("content://media/external/images/media");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, REQ_SELECT);
} else if(item==1) {
//카메라로 찍기
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
})
.show();
}
}
//////////////////////////// 선택 하면 리턴값 받기
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
try {
if(!intent.getData().equals(null)){
Bitmap selPhoto = Images.Media.getBitmap(getContentResolver(), intent.getData());
selPhoto = Bitmap.createScaledBitmap(selPhoto, 100, 100, true);
// image_bt.setImageBitmap(selPhoto);//썸네일
Log.e("선택 된 이미지 ", "selPhoto : " + selPhoto);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
'Android > Tip&Tech' 카테고리의 다른 글
Android 갤러리에서 filepath(Action_PICK) (0) | 2015.01.22 |
---|---|
Android StrictMode Mode 설정/해제하기 (0) | 2015.01.19 |
[펌]액션바의 searchview 검색 후 닫기 (0) | 2015.01.06 |
[펌]ActionBar SearchView 커스터마이징하기 (0) | 2015.01.06 |
ActionBar 설명 (0) | 2015.01.06 |