Hier versuche ich, einen Screenshot zu machen und auch in SD-Karte zu speichern, aber ich versage beim Speichern. Bitte hilf mir.Um Screenshot zu machen und es in SD-Karte zu speichern
public void onClick(View OnclickView) {
boolean success = false;
view = OnclickView.getRootView();
view.setDrawingCacheEnabled(true);
bitmap = view.getDrawingCache();
ScreenShotHold.setImageBitmap(bitmap);
bitmap.compress(Bitmap.CompressFormat.PNG, 60, bytearrayoutputstream);
File sdCardDirectory = Environment.getExternalStorageDirectory();
File image = new File(sdCardDirectory, "test.png");
boolean success = false;
// Encode the file as a PNG image.
FileOutputStream outStream;
try {
outStream = new FileOutputStream(image);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
Toast.makeText(getApplicationContext(), "bitmap " + bitmap, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "outstream " + outStream, Toast.LENGTH_SHORT).show();
/* 100 to keep full quality of the image */
outStream.flush();
outStream.close();
success = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (success == true) {
Toast.makeText(getApplicationContext(), "Saved", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
}
}
Hier bekomme ich fehlgeschlagenes Ergebnis, aber ich bekomme einen Screenshot.
mein Verständnis ist, dass man auf den ersten Satz von Berechtigungen in Manifest für SD-Karte – ziondreamt
Ya Ich habe getan haben müssen, aber ich bin nicht zu bekommen. – Kogile
auf welcher Android-Version versuchen Sie dies – Piyush