Advertisement
ms_olin

Untitled

May 7th, 2017
1,911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. // First check if device is supporting flashlight or not
  2. hasFlash = getApplicationContext().getPackageManager()
  3.         .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
  4.  
  5. if (!hasFlash) {
  6.     // device doesn't support flash
  7.     // Show alert message and close the application
  8.     AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create();
  9.     alert.setTitle("Error");
  10.     alert.setMessage("Sorry, your device doesn't support flash light!");
  11.     alert.setButton("OK", new DialogInterface.OnClickListener() {
  12.         public void onClick(DialogInterface dialog, int which) {
  13.             // closing the application
  14.             finish();
  15.         }
  16.     });
  17.     alert.show();
  18.     return;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement