2

SDカードにビットマップを保存していて、Intent.ACTION_MEDIA_MOUNTED直後に呼び出しました。

ギャラリーに表示されますが、画像が表示されるまでに約 5 分かかります。瞬時にする方法はありますか?

File newFile = new File(newFilename);
if (newFile.exists()) { 
    newFile.delete();
}

try {
   FileOutputStream out = new FileOutputStream(newFile);
   bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
   out.flush();
   out.close();
   context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
   Toast.makeText(context, "Photo will appear in the Gallery in a few minutes.", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
   e.printStackTrace();
}
4

3 に答える 3

0
We can use this way also

protected void onActivityResult(int requestCode, int resultCode,
            Intent resultData) {
        super.onActivityResult(requestCode, resultCode, resultData);

        Log.v(TAG + ".onActivityResult", "onActivityResult");


         if (resultData != null) {

                Uri selectedImage = resultData.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };

                Cursor cursor = getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);

                uploadImagePath = cursor.getString(columnIndex);
                bitmapUploadImage = BitmapFactory.decodeFile(uploadImagePath);

                cursor.close();
于 2013-05-13T18:22:53.090 に答える