public boolean processCommand(String command, String params) {
   if (command.equals("launchBrowser")) {
     try {
       Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(params));
       startActivity(i);
       return true;
     } catch (Exception e) {
       // No browser?
       Log.e(TAG, e.toString());
       return false;
     }
   } else if (command.equals("launchEmail")) {
     try {
       Intent send = new Intent(Intent.ACTION_SENDTO);
       String uriText;
       uriText = "mailto:[email protected]" + "?subject=Your app is..." + "&body=great! Or?";
       uriText = uriText.replace(" ", "%20");
       Uri uri = Uri.parse(uriText);
       send.setData(uri);
       startActivity(Intent.createChooser(send, "E-mail the app author!"));
       return true;
     } catch (Exception e) { // For example, android.content.ActivityNotFoundException
       Log.e(TAG, e.toString());
       return false;
     }
   } else if (command.equals("sharejpeg")) {
     try {
       Intent share = new Intent(Intent.ACTION_SEND);
       share.setType("image/jpeg");
       share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + params));
       startActivity(Intent.createChooser(share, "Share Picture"));
       return true;
     } catch (Exception e) { // For example, android.content.ActivityNotFoundException
       Log.e(TAG, e.toString());
       return false;
     }
   } else if (command.equals("sharetext")) {
     try {
       Intent sendIntent = new Intent();
       sendIntent.setType("text/plain");
       sendIntent.putExtra(Intent.EXTRA_TEXT, params);
       sendIntent.setAction(Intent.ACTION_SEND);
       startActivity(sendIntent);
       return true;
     } catch (Exception e) { // For example, android.content.ActivityNotFoundException
       Log.e(TAG, e.toString());
       return false;
     }
   } else if (command.equals("showTwitter")) {
     try {
       String twitter_user_name = params;
       try {
         startActivity(
             new Intent(
                 Intent.ACTION_VIEW,
                 Uri.parse("twitter://user?screen_name=" + twitter_user_name)));
       } catch (Exception e) {
         startActivity(
             new Intent(
                 Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + twitter_user_name)));
       }
       return true;
     } catch (Exception e) { // For example, android.content.ActivityNotFoundException
       Log.e(TAG, e.toString());
       return false;
     }
   } else if (command.equals("launchMarket")) {
     // Don't need this, can just use launchBrowser with a market:
     // http://stackoverflow.com/questions/3442366/android-link-to-market-from-inside-another-app
     // http://developer.android.com/guide/publishing/publishing.html#marketintent
     return false;
   } else if (command.equals("toast")) {
     Toast toast = Toast.makeText(this, params, Toast.LENGTH_SHORT);
     toast.show();
     Log.i(TAG, params);
     return true;
   } else if (command.equals("showKeyboard") && mSurfaceView != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
     // No idea what the point of the ApplicationWindowToken is or if it
     // matters where we get it from...
     inputMethodManager.toggleSoftInputFromWindow(
         mSurfaceView.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
     return true;
   } else if (command.equals("hideKeyboard") && mSurfaceView != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.toggleSoftInputFromWindow(
         mSurfaceView.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
     return true;
   } else if (command.equals("inputbox")) {
     String title = "Input";
     String defString = "";
     String[] param = params.split(":");
     if (param[0].length() > 0) title = param[0];
     if (param.length > 1) defString = param[1];
     Log.i(TAG, "Launching inputbox: " + title + " " + defString);
     inputBox(title, defString, "OK");
     return true;
   } else if (command.equals("vibrate") && mSurfaceView != null) {
     int milliseconds = -1;
     if (params != "") {
       try {
         milliseconds = Integer.parseInt(params);
       } catch (NumberFormatException e) {
       }
     }
     // Special parameters to perform standard haptic feedback
     // operations
     // -1 = Standard keyboard press feedback
     // -2 = Virtual key press
     // -3 = Long press feedback
     // Note that these three do not require the VIBRATE Android
     // permission.
     switch (milliseconds) {
       case -1:
         mSurfaceView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
         break;
       case -2:
         mSurfaceView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
         break;
       case -3:
         mSurfaceView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
         break;
       default:
         if (vibrator != null) {
           vibrator.vibrate(milliseconds);
         }
         break;
     }
     return true;
   } else if (command.equals("finish")) {
     finish();
   } else if (command.equals("rotate")) {
     updateScreenRotation();
     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
       Log.i(TAG, "Must recreate activity on rotation");
     }
   } else if (command.equals("immersive")) {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
       updateSystemUiVisibility();
     }
   } else if (command.equals("recreate")) {
     exitEGLRenderLoop();
     recreate();
   } else if (command.equals("ask_permission") && params.equals("storage")) {
     askForStoragePermission();
   }
   return false;
 }