Nullzeiger-Ausnahme beim Klicken auf die Kamera, um ein Bild aufzunehmen

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Nullzeiger-Ausnahme beim Klicken auf die Kamera, um ein Bild aufzunehmen

by Guest » 14 Jan 2025, 13:02

Ich habe eine Android-App, die den Standort erfasst. Ich habe versucht, die auf Android 15 erforderlichen Berechtigungen und auch den übergebenen Kontext zu überprüfen. Helfen Sie mir, das Problem zu verfolgen und zu beheben, da es nur auf Gerät 15 auftritt. Der folgende Code funktioniert einwandfrei für alle Geräte mit Android 14 und niedriger, aber auf Android 15 verursacht er einen Absturz mit der folgenden Meldung.
Ausnahme ist: java.lang.NullPointerException: Versuch, die Schnittstellenmethode „void ant.co.in.geotagginglibraryLocationApp.GeoLocationPopup$OnCameraClickedListener.capture()“ aufzurufen auf einer Nullobjektreferenz
bei anant.co.in.geotagginglibraryLocationApp.GeoLocationPopup$1.onClick(GeoLocationPopup.java:183)
Ich füge den Code bei, bitte helfen Sie bei der Lösung .

Code: Select all

 addlocation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
addlocation.setEnabled(false);
if (!showValidations(context)) {
onCameraClickedListener.capture();
addlocation.setEnabled(true);
}
addlocation.setEnabled(true);
}
});

private void openCamera() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = imageUtils.createImageFile(PREFIX_GEO_TAG_IMG);
} catch (IOException ex) {
ex.printStackTrace();
}
if (photoFile != null) {
imagePath = photoFile.getAbsolutePath();
Uri photoURI = FileProvider.getUriForFile(getActivity(), "anant.co.in.geotagginglibraryAculife.FileProvider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_CAPTURE_IMAGE);
}
}
}

doctortag.setOnCameraClickedListener(new GeoLocationPopup.OnCameraClickedListener() {
@Override
public void capture() {
openCamera();
}
});

Top