如何使用getContentResolver()全屏退出后删除图像.delete(uri,null,null);

时间:2014-04-03 09:57:08

标签: java android image share

我有FullscreenActivity,退出后我想删除它制作的图像。 使用我的代码,图片在共享意图之前被删除,因此共享无效。

计划B / QuestionB将如何将我的代码保存在自己的文件夹而不是相机文件夹中?

我希望你有个主意。

    public class FullImageActivity extends Activity {



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.full_image);

        // get intent data
        Intent i = getIntent();

        // Selected image id
        int position = i.getExtras().getInt("id");
        ImageAdapter imageAdapter = new ImageAdapter(this);

        ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
        imageView.setImageResource(imageAdapter.mThumbIds[position]);
        BitmapDrawable bm = (BitmapDrawable) imageView.getDrawable();
        Bitmap mysharebmp = bm.getBitmap();
        String path = Images.Media.insertImage(getContentResolver(),    
                            mysharebmp, "MyImage", null);
        Uri uri = Uri.parse(path);

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("image/*");
        sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(Intent.createChooser(sharingIntent,
                            "Share image using"));
        getContentResolver().delete(uri, null, null);
        sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(path))));


    }

}

0 个答案:

没有答案