Ich bin Bild mit Absicht erfassen und an meinen Server senden, aber wenn ich Bild erfassen und dann einige mobile komprimieren, bekomme ich bitmap.compress Error. So, wie dieses Problem zu lösen Jungs dies ist mein CodeIch erhalte einen Fehler, wenn ich das Bild mit Bitmap in Android komprimiere
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap bitmap = BitmapFactory.decodeFile(fileUri.getPath(), options);
File f = new File(fileUri.getPath());
OutputStream outputStream = null;
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream = new FileOutputStream(f);
outputStream.flush();
outputStream.close();
ImageView image = new ImageView(I_kycActivity.this);
image.setLayoutParams(new android.view.ViewGroup.LayoutParams(250, 250));
image.setMaxHeight(400);
image.setMaxWidth(400);
image.setPadding(5, 5, 5, 5);
image.setImageBitmap(bitmap);
if (phototype.equals("Photo")) {
img_photo.setImageBitmap(bitmap);
txtphote.setText(f.getName());
imgUrl.add(f.getPath());
}
und Fehler
12-30 15: 33: 23,485 9564-9564/com.riya.product.intranet W/System.err: java.lang.NullPointerException: Es wurde versucht, die virtuelle Methode 'boolean android.graphics.Bitmap.compress (android.graphics.Bitmap $ CompressFormat, int, java.io.OutputStream) für eine Nullobjekt-Referenz aufzurufen. 12- 30 15: 33: 23.487 9564-9564/com.riya.product.intranet W/System.err: at com.riya.product.salestraster.I_kycActivity.previewCapturedImage (I_kycActivity.java:1124) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet W/System.err: at com.riya.product.salestraster.I_kycActivity.onActivityResult (I_kycActivity.java:1257) 12-30 15 : 33: 23.488 9564-9564/com.riya.product.intranet W/System.err: bei android.app.Activity.dispatchActivityResult (Activity.java:6919) 12-30 15: 33: 23.488 9564-9564/com .riya.product.intranet W/System.err: at android.app.ActivityThread.deliverResults (ActivityThread.java:4174) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet W/System .err: at android.app.ActivityThread.handleSendResult (ActivityThread.java:4221) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet Mit System.err: at android.app.ActivityThread .-wrap20 (ActivityThread.java) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet Mit System.err: at android.app.ActivityThread $ H.handleMes Salbei (ActivityThread.java:1583) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet W/System.err: bei android.os.Handler.dispatchMessage (Handler.java:110) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet W/System.err: at android.os.Looper.loop (Looper.java:203) 12-30 15: 33: 23.488 9564 -9564/com.riya.product.intranet W/System.err: at android.app.ActivityThread.main (ActivityThread.java:6251) 12-30 15: 33: 23.488 9564-9564/com.riya.product. Intranet W/System.err: at java.lang.reflect.Method.invoke (systemeigene Methode) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet W/System.err: at com. android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1075) 12-30 15: 33: 23.488 9564-9564/com.riya.product.intranet W/System.err: at com.android.internal .os.ZygoteInit.main (ZygoteInit.java:936)
Noch Fehler ich bin immer auf einige Mobil. z.B. Moto c + – suraj
Besuchen Sie [Was ist NullPointerException und wie behebe ich es] (https://stackoverflow.com/questions/218384/what-isa-nullpointerexception-and-how-do-fix-it) – Yousaf
NullPointerException Ich habe in bitmap.compress (Bitmap.CompressFormat.JPEG, 100, outputStream); diese Zeile. Nicht jedes Telefon außer einem Telefon habe ich Fehler in dieser Zeile. speziell "Moto c plus" Modell – suraj