FELIX MANYANDA
- Forum posts: 1
Jan 24, 2017, 3:52:12 PM via Website
Jan 24, 2017 3:52:12 PM via Website
I am creating android photo editing app. The button for saving image is not working, Code below. Thanks in advance.
public class MainActivity extends AppCompatActivity {
ImageView buckysImageView;
Drawable buckysFace;
Bitmap bitmapImage;
Bitmap pic;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buckysImageView = (ImageView) findViewById(R.id.buckysImageView);
Drawable layers[] = new Drawable[2];
layers[0] = ResourcesCompat.getDrawable(getResources(), R.drawable.brick, null);
layers[1] = ResourcesCompat.getDrawable(getResources(), R.drawable.building, null);
LayerDrawable layerDrawable = new LayerDrawable(layers);
buckysImageView.setImageDrawable(layerDrawable);
final Button button = (Button) findViewById(R.id.savePicture);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
buckysImageView.buildDrawingCache();
Bitmap bm=buckysImageView.getDrawingCache();
MediaStore.Images.Media.insertImage(getContentResolver(), bm, "title", "description");
}
});
}
Thanks;
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.