how to take screenshot programmatically and save it on gallery?

后端 未结 4 2084
遇见更好的自我
遇见更好的自我 2020-12-18 06:49

i would to know what is the code to take a screenshot of the current screen (after a press of a button) and save it on a gallery because I don\'t have a device with sd cards

4条回答
  •  盖世英雄少女心
    2020-12-18 07:15

        View v1 = L1.getRootView();
        v1.setDrawingCacheEnabled(true);
        Bitmap bm = v1.getDrawingCache();
        BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
        image = (ImageView) findViewById(R.id.screenshots);
        image.setBackgroundDrawable(bitmapDrawable);
    

    For complete source code go through the below blog

    http://amitandroid.blogspot.in/2013/02/android-taking-screen-shots-through-code.html

    For storing the Bitmap to see the below link

    Android Saving created bitmap to directory on sd card

提交回复
热议问题