解决方法
清单代码:
<receiver android:name=".pictureReceiver" > <intent-filter android:priority="10000" > <action android:name="com.android.camera.NEW_PICTURE"/> <data android:mimeType="image/*"/> </intent-filter> </receiver>
onReceive代码:
@Override public void onReceive(Context arg0,Intent arg1) { String selectedImageUri = arg1.getData().getPath(); Log.d("TAG","Received new photo:::"+selectedImageUri ); Log.d("TAG","file Path"+getRealPathFromURI(arg1.getData(),arg0)); } public String getRealPathFromURI(Uri contentUri,Context context) { try { String[] proj = {MediaStore.Images.Media.DATA}; Cursor cursor = context.getContentResolver().query(contentUri,proj,null,null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } catch (Exception e) { return contentUri.getPath(); } }