William Willi William Willi - 7 months ago 54
Android Question

i get null pointer NullPointerException from onPause() method

i have made an Qr-Scanner now the activity has button. if i click the button it opens the scanner so i'm doing good with it, but if i go back to the previous activity without clicking the button i get the NullPointerException from the onPause() .

public void onPause() {



if i go to previous activity without opening the camera then it is giving the error. someone help me


If you want to prevent stop() method from being called if the camera is not started, you must use a boolean expression to check.

inside onPause method:

if(mScannerView != null){