if(camera == null){
Toast.makeText(getBaseContext(),"without camera",Toast.LENGTH_LONG).show(); 
return;
  }
-------------------------------------------------------------------------------------------- add full code
button.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
    if (isLightOn) {
     p.setFlashMode(Parameters.FLASH_MODE_OFF);
     camera.setParameters(p);
     camera.stopPreview();
     isLightOn = false;
     Toast.makeText(context, R.string.off, Toast.LENGTH_SHORT).show();
    } else {
     p.setFlashMode(Parameters.FLASH_MODE_TORCH);
     camera.setParameters(p);
     camera.startPreview();
     isLightOn = true;
     Toast.makeText(context, R.string.on, Toast.LENGTH_SHORT).show();
    }
   }
  });
Sorry for my Eng.
How do I make that when you click on the button to check for flash the phone? And when no flash - display a message (Toast)
 
    