Beispiel #1
0
 /**
  * Go to the camera if the camera button is pressed, go back to WildlifeImages if back is pressed
  * at camera. Gives info on what key pressed and whether it was pressed or released.
  *
  * @param context The application's environment.
  * @param keyCode The button that was pushed.
  * @param event Not used.
  * @return True if the camera or back buttons were pressed, else false.
  */
 public static boolean onKeyDown(Activity context, int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_CAMERA) {
     Common.startCamera(context);
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_BACK) {
     context.onBackPressed();
     return true;
   } else {
     return false;
   }
 } /* CommonUnitTest */
Beispiel #2
0
  /**
   * Checks if you have an application to scan a QR code and launch it if you have one.
   *
   * @param context The activity to serve as the parent of the new activity
   */
  public static void startScan(WireActivity context) {
    boolean scanAvailable =
        Common.isIntentAvailable(context, context.loadString(R.string.intent_action_scan));
    boolean scan2Available =
        Common.isIntentAvailable(context, context.loadString(R.string.intent_action_scan_2));

    if (scanAvailable) {
      Intent intent = new Intent(context.loadString(R.string.intent_action_scan));
      intent.putExtra(
          context.loadString(R.string.intent_extra_scan_mode),
          context.loadString(R.string.intent_qr_mode));
      context.startActivityForResult(intent, context.loadInt(R.integer.CODE_SCAN_ACTIVITY_REQUEST));
    } else if (scan2Available) {
      Intent intent = new Intent(context.loadString(R.string.intent_action_scan_2));
      context.startActivityForResult(
          intent, context.loadInt(R.integer.CODE_SCAN_2_ACTIVITY_REQUEST));
    } else {
      context.showDialog(WireActivity.SCAN_DIALOG);
    }
  } /* CommonUnitTest */