public void openBrowser(String url) {
   if (url.startsWith("market:")) {
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
     context.startActivity(intent);
   } else if (url.startsWith("http:") || url.startsWith("https:")) {
     Intent intent = new Intent(context, MRAIDBrowser.class);
     intent.putExtra(MRAIDBrowser.URL_EXTRA, url);
     intent.putExtra(
         MRAIDBrowser.MANAGER_EXTRA, nativeFeatureManager.getSupportedNativeFeatures());
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     context.startActivity(intent);
   }
 }
 public void storePicture(final String url) {
   if (nativeFeatureManager.isStorePictureSupported()) {
     // Spawn a new thread to download and save the image
     new Thread(
             new Runnable() {
               @Override
               public void run() {
                 try {
                   storePictureInGallery(url);
                 } catch (Exception e) {
                   MRAIDLog.e(TAG, e.getLocalizedMessage());
                 }
               }
             })
         .start();
   }
 }
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  @SuppressLint("SimpleDateFormat")
  public void createCalendarEvent(String eventJSON) {
    if (!nativeFeatureManager.isCalendarSupported()) {
      return;
    }
    try {
      // Need to fix some of the encoded string from JS
      eventJSON = eventJSON.replace("\\", "").replace("\"{", "{").replace("}\"", "}");
      JSONObject jsonObject = new JSONObject(eventJSON);

      String description = jsonObject.optString("description", "Untitled");
      String location = jsonObject.optString("location", "unknown");
      String summary = jsonObject.optString("summary");

      /*
       * NOTE: The Java SimpleDateFormat class will not work as is with the W3C spec for
       * calendar entries. The problem is that the W3C spec has time zones (UTC offsets)
       * containing a colon like this:
       *   "2014-12-21T12:34-05:00"
       * The SimpleDateFormat parser will choke on the colon. It wants something like this:
       *   "2014-12-21T12:34-0500"
       *
       * Also, the W3C spec indicates that seconds are optional, so we have to use two patterns
       * to be able to parse both this:
       *   "2014-12-21T12:34-0500"
       * and this:
       *   "2014-12-21T12:34:56-0500"
       */

      String[] patterns = {
        "yyyy-MM-dd'T'HH:mmZ", "yyyy-MM-dd'T'HH:mm:ssZ",
      };

      String[] dateStrings = new String[2];
      dateStrings[0] = jsonObject.getString("start");
      dateStrings[1] = jsonObject.optString("end");

      long startTime = 0;
      long endTime = 0;

      for (int i = 0; i < dateStrings.length; i++) {
        if (TextUtils.isEmpty(dateStrings[i])) {
          continue;
        }
        // remove the colon in the timezone
        dateStrings[i] = dateStrings[i].replaceAll("([+-]\\d\\d):(\\d\\d)$", "$1$2");
        for (String pattern : patterns) {
          try {
            SimpleDateFormat sdf = new SimpleDateFormat(pattern);
            if (i == 0) {
              startTime = sdf.parse(dateStrings[i]).getTime();
            } else {
              endTime = sdf.parse(dateStrings[i]).getTime();
            }
            break;
          } catch (ParseException e) {
            continue;
          }
        }
      }

      /*
      boolean wholeDay = false;
      if (jObject.getJSONObject("recurrence") != null) {
      	JSONObject recurrence = jObject.getJSONObject("recurrence");
      	if (recurrence.getString("frequency") != null) {
      		wholeDay = recurrence.getString("frequency").toLowerCase().equals("daily");
      	}
      }
      */

      Intent intent = new Intent(Intent.ACTION_INSERT).setType("vnd.android.cursor.item/event");
      intent.putExtra(Events.TITLE, description);
      intent.putExtra(Events.DESCRIPTION, summary);
      intent.putExtra(Events.EVENT_LOCATION, location);

      if (startTime > 0) {
        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime);
      }

      if (endTime > 0) {
        intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime);
      }

      /*
      if (wholeDay) {
      	intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, wholeDay);
      }
      */

      context.startActivity(intent);
    } catch (JSONException e) {
      MRAIDLog.e(TAG, "Error parsing JSON: " + e.getLocalizedMessage());
    }
  }
 public final void callTel(String url) {
   if (nativeFeatureManager.isTelSupported()) {
     Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
     context.startActivity(intent);
   }
 }
 public void sendSms(String url) {
   if (nativeFeatureManager.isSmsSupported()) {
     Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(url));
     context.startActivity(intent);
   }
 }