我在onActivityResult方法中獲得的Uri,我試圖讓全局Uri變量來讓Uri使用Intent putExtra方法將它發送給另一個活動..但它顯示無法解析符號。如何從onActivityResult方法獲取URI數據以發送到其他活動?
selectedImage變量在onActivityResult方法中,我希望Uri變量的值在方法外,以便我可以使用Intent將該Uri發送給另一個活動。
如何獲取它的值作爲onActivityResult的返回類型是無效的?
幫幫我還是有其他方法嗎?
公共無效onClickPickImage(查看視圖){
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, 0);//zero can be replaced with any action code
Intent pickPhoto = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(pickPhoto , 1);//one can be replaced with any action code
}
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case 0:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
}
break;
case 1:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
}
break;
}
}
離不開代碼 –
你能後的代碼幫助? –
參見'Intent#getData' /'Intent#setData' – pskink