- Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
- // 告诉打开的内容
- intent.setType("file:///sdcard/image/*" );
- startActivityForResult(intent, 1 );
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
// 告诉打开的内容
intent.setType("file:///sdcard/image/*");
startActivityForResult(intent, 1);
- protected final void onActivityResult( final int requestCode, final int
- resultCode, final Intent i) {
- super .onActivityResult(requestCode, resultCode, i);
- // this matches the request code in the above call
- if (requestCode == 1 ) {
- Uri _uri = i.getData();
- // this will be null if no image was selected...
- if (_uri != null ) {
- // now we get the path to the image file
- cursor = getContentResolver().query(_uri, null ,
- null , null , null );
- cursor.moveToFirst();
- String imageFilePath = cursor.getString(0 );
- cursor.close();
- }
- }