Ejemplo n.º 1
1
    @Override
    public void onClick(View v) {
      if (v == btn_addjob) {
        EditJobFragment editjobfragment = new EditJobFragment();
        FragmentUtil.addFragment(activity, editjobfragment, null, false, true, "EditJobFragment");

      } else if (v == btn_addquote) {
        AddQuoteFragment addquotefragment = new AddQuoteFragment();
        FragmentUtil.addFragment(activity, addquotefragment, null, false, true, "AddQuoteFragment");

      } else if (v == phone) {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:7416083252"));
        startActivity(callIntent);

      } else if (v == home) {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:7416083252"));
        startActivity(callIntent);

      } else if (v == btn_view_customer) {

        LeadViewCustomer leadviewcustomer = new LeadViewCustomer();
        FragmentUtil.addFragment(activity, leadviewcustomer, null, false, true, "LeadViewCustomer");
      }
    }
Ejemplo n.º 2
1
    /**
     * In order to update notification from the AlarmSender.
     *
     * @param oldName <code>String</code> - old name
     * @param oldDescription <code>String</code> - old description
     * @param oldDate <code>String</code> - old date
     * @param newName <code>String</code> - new name
     * @param newDescription <code>String</code> - new description
     * @param newDate <code>String</code> - new date
     */
    @android.webkit.JavascriptInterface
    public void updateAlarmPerToDoItem(
        String oldName,
        String oldDescription,
        String oldDate,
        String newName,
        String newDescription,
        String newDate) {
      long oldTime = ParseDateToTimeStamp(oldDate);
      Intent oldIntent = new Intent(MainActivity.this, NotificationService.class);
      oldIntent.putExtra("name", oldName);
      oldIntent.putExtra("description", oldDescription);
      oldIntent.putExtra("time", oldTime);
      int oldId = (oldName + oldDescription + oldTime).hashCode();
      oldIntent.setData(Uri.parse(String.valueOf(oldId)));
      PendingIntent oldPendingIntent =
          PendingIntent.getService(
              MainActivity.this, 0, oldIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
      alarmManager.cancel(oldPendingIntent);

      long newTime = ParseDateToTimeStamp(newDate);
      Intent newIntent = new Intent(MainActivity.this, NotificationService.class);
      oldIntent.putExtra("name", newName);
      oldIntent.putExtra("description", newDescription);
      oldIntent.putExtra("time", newTime);
      int newId = (newName + newDescription + newTime).hashCode();
      newIntent.setData(Uri.parse(String.valueOf(newId)));
      PendingIntent newPendingIntent =
          PendingIntent.getService(
              MainActivity.this, 0, newIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      alarmManager.set(AlarmManager.RTC_WAKEUP, newTime, newPendingIntent);
    }
Ejemplo n.º 3
1
  /** {@inheritDoc} */
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    final Cursor cursor = (Cursor) mAdapter.getItem(position);
    final String trackId;

    if (cursor != null) {
      trackId = cursor.getString(TracksAdapter.TracksQuery.TRACK_ID);
    } else {
      trackId = CoscupContract.Tracks.ALL_TRACK_ID;
    }

    final Intent intent = new Intent(Intent.ACTION_VIEW);
    final Uri trackUri = CoscupContract.Tracks.buildTrackUri(trackId);
    intent.putExtra(SessionDetailFragment.EXTRA_TRACK, trackUri);

    if (cursor == null) {
      intent.setData(CoscupContract.Sessions.CONTENT_URI);
    } else {
      intent.setData(CoscupContract.Tracks.buildSessionsUri(trackId));
    }

    ((BaseActivity) getActivity()).openActivityOrFragment(intent);

    getListView().setItemChecked(position, true);
  }
Ejemplo n.º 4
1
  public void onDocumentPicked(DocumentInfo doc) {
    final FragmentManager fm = getFragmentManager();
    if (doc.isDirectory()) {
      mState.stack.push(doc);
      mState.stackTouched = true;
      onCurrentDirectoryChanged(ANIM_DOWN);
    } else if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
      // Explicit file picked, return
      new ExistingFinishTask(doc.derivedUri).executeOnExecutor(getCurrentExecutor());
    } else if (mState.action == ACTION_CREATE) {
      // Replace selected file
      SaveFragment.get(fm).setReplaceTarget(doc);
    } else if (mState.action == ACTION_MANAGE) {
      // First try managing the document; we expect manager to filter
      // based on authority, so we don't grant.
      final Intent manage = new Intent(DocumentsContract.ACTION_MANAGE_DOCUMENT);
      manage.setData(doc.derivedUri);

      try {
        startActivity(manage);
      } catch (ActivityNotFoundException ex) {
        // Fall back to viewing
        final Intent view = new Intent(Intent.ACTION_VIEW);
        view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        view.setData(doc.derivedUri);

        try {
          startActivity(view);
        } catch (ActivityNotFoundException ex2) {
          /// M: Show toast with enhance way.
          showToast(R.string.toast_no_application);
        }
      }
    }
  }
Ejemplo n.º 5
0
 @Override
 public void onInfoWindowClick(Marker marker) {
   switch (marker.getTitle()) {
     case "Indicative":
       {
         Intent indIntent = new Intent(Intent.ACTION_VIEW);
         indIntent.setData(Uri.parse(indURL));
         startActivity(indIntent);
       }
       break;
     case "Zirka":
       {
         Intent zirIntent = new Intent(Intent.ACTION_VIEW);
         zirIntent.setData(Uri.parse(zirURL));
         startActivity(zirIntent);
       }
       break;
     case "Hydrosila":
       {
         Intent hydIntent = new Intent(Intent.ACTION_VIEW);
         hydIntent.setData(Uri.parse(hydURL));
         startActivity(hydIntent);
       }
       break;
   }
 }
Ejemplo n.º 6
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d(TAG, "onUpdate");

    for (int i = 0; i < appWidgetIds.length; i++) {
      int appWidgetId = appWidgetIds[i];

      Intent intent = new Intent(context, StackWidgetService.class);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      views.setRemoteAdapter(appWidgetId, R.id.stack_view, intent);
      views.setEmptyView(R.id.stack_view, R.id.empty_view);

      Intent toastIntent = new Intent(context, FootballScoreWidget.class);
      toastIntent.setAction(FootballScoreWidget.OPEN_ACTIVITY_ACTION);
      toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      PendingIntent toastPendingIntent =
          PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      views.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

      appWidgetManager.updateAppWidget(appWidgetId, views);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
Ejemplo n.º 7
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   switch (position) {
     case 0: // Launch Navigation to the conference site
       Intent i =
           new Intent(
               android.content.Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_map_place)));
       startActivity(i);
       break;
     case 1: // Display the Open Source projects used for this application
       Intent i1 = new Intent(getApplicationContext(), LibsActivity.class);
       i1.putExtra(Libs.BUNDLE_FIELDS, Libs.toStringArray(R.string.class.getFields()));
       i1.putExtra(Libs.BUNDLE_LIBS, new String[] {"OpenCSV", "PrettySharedPreferences"});
       i1.putExtra(Libs.BUNDLE_VERSION, true);
       i1.putExtra(Libs.BUNDLE_LICENSE, true);
       i1.putExtra(Libs.BUNDLE_TITLE, "Open Source");
       i1.putExtra(Libs.BUNDLE_THEME, R.style.AppThemeBar);
       startActivity(i1);
       break;
     case 2: // Open my twitter ;)
       Intent i2 = new Intent(Intent.ACTION_VIEW);
       i2.setData(Uri.parse("http://twitter.com/Tajchert"));
       startActivity(i2);
       break;
     case 3: // Open the feedback form
       Intent i3 = new Intent(Intent.ACTION_VIEW);
       i3.setData(Uri.parse(getString(R.string.url_feedback_form)));
       startActivity(i3);
       break;
   }
 }
Ejemplo n.º 8
0
 private boolean callWeChat() {
   Uri contentUrl = Uri.parse(ConfigUtil.getString(Keys.URL_WECHAT));
   Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.addCategory(Intent.CATEGORY_BROWSABLE);
   intent.setData(contentUrl);
   PackageManager pm = getPackageManager();
   List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0);
   Collections.sort(resInfo, new ResolveInfo.DisplayNameComparator(pm));
   List<Intent> targetedIntents = new ArrayList<Intent>();
   for (ResolveInfo info : resInfo) {
     Intent targeted = new Intent(Intent.ACTION_VIEW);
     ActivityInfo activityInfo = info.activityInfo;
     if (activityInfo.packageName.equals("com.tencent.mm")) {
       targeted.setData(contentUrl);
       targeted.setPackage(activityInfo.packageName);
       targeted.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
       targetedIntents.add(targeted);
     }
   }
   if (targetedIntents.isEmpty()) {
     return false;
   }
   Intent chooser =
       Intent.createChooser(targetedIntents.remove(0), getString(R.string.title_choose_wechat));
   chooser.setClassName("android", "com.android.internal.app.ResolverActivity");
   chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedIntents.toArray(new Parcelable[] {}));
   try {
     startActivity(chooser);
   } catch (ActivityNotFoundException e) {
     return false;
   }
   return true;
 }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // update each of the widgets with the remote adapter
    for (int i = 0; i < appWidgetIds.length; ++i) {

      // Here we setup the intent which points to the StackViewService which will
      // provide the views for this collection.
      Intent intent = new Intent(context, StackWidgetService.class);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      // When intents are compared, the extras are ignored, so we need to embed the extras
      // into the data so that the extras will not be ignored.
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

      // The empty view is displayed when the collection has no items. It should be a sibling
      // of the collection view.
      rv.setEmptyView(R.id.stack_view, R.id.empty_view);

      // Here we setup the a pending intent template. Individuals items of a collection
      // cannot setup their own pending intents, instead, the collection as a whole can
      // setup a pending intent template, and the individual items can set a fillInIntent
      // to create unique before on an item to item basis.
      Intent toastIntent = new Intent(context, StackWidgetProvider.class);
      toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
      toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      PendingIntent toastPendingIntent =
          PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

      appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
Ejemplo n.º 10
0
 public void signup(LoginResultListener paramLoginResultListener)
 {
   Intent localIntent = new Intent("android.intent.action.VIEW");
   if (ConfigHelper.disableweblogin)
   {
     localIntent.setData(Uri.parse("dianping://signup"));
     localIntent.setFlags(335544320);
     this.context.startActivity(localIntent);
     this.loginResultListener = paramLoginResultListener;
     return;
   }
   String str2 = LoginUtils.getLoginGASource(this.context);
   String str3 = Environment.versionName();
   String str4 = Environment.mapiUserAgent();
   String str5 = preferences(DPApplication.instance()).getString("dpid", "");
   Object localObject = DPApplication.instance().locationService().location();
   String str1;
   if (localObject != null)
     str1 = Location.FMT.format(((DPObject)localObject).getDouble("Lat"));
   for (localObject = Location.FMT.format(((DPObject)localObject).getDouble("Lng")); ; localObject = "0")
   {
     localIntent.setData(Uri.parse("dianping://loginweb?url=http://m.dianping.com/reg/mobile/app&version=" + str3 + "&agent=" + str4 + "&dpid=" + str5 + "&gasource=" + str2 + "&lat=" + str1 + "&lng=" + (String)localObject));
     break;
     str1 = "0";
   }
 }
Ejemplo n.º 11
0
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == aboutOtaUpdater) {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse(Config.WEB_HOME_URL));
      startActivity(i);
    } else if (preference == license) {
      Intent i = new Intent(getActivity(), License.class);
      startActivity(i);
    } else if (preference == followGPlus) {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse(Config.GPLUS_URL));
      startActivity(i);
    } else if (preference == contribPref) {
      Intent i = new Intent(getActivity(), Contributors.class);
      startActivity(i);
    } else if (preference == feedbackPref) {
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse(Config.WEB_FEEDBACK_URL));
      startActivity(i);
    } else {
      return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

    return true;
  }
Ejemplo n.º 12
0
  /**
   * Display a new browser with the specified URL.
   *
   * @param url The url to load.
   * @param usePhoneGap Load url in PhoneGap webview
   * @return "" if ok, or error message.
   */
  public String openExternal(String url, boolean usePhoneGap) {
    try {
      Intent intent = null;
      if (usePhoneGap) {
        intent =
            new Intent().setClass(this.cordova.getActivity(), org.apache.cordova.DroidGap.class);
        intent.setData(Uri.parse(url)); // This line will be removed in future.
        intent.putExtra("url", url);

        // Timeout parameter: 60 sec max - May be less if http device timeout is less.
        intent.putExtra("loadUrlTimeoutValue", 60000);

        // These parameters can be configured if you want to show the loading dialog
        intent.putExtra("loadingDialog", "Wait,Loading web page..."); // show loading dialog
        intent.putExtra(
            "hideLoadingDialogOnPageLoad", true); // hide it once page has completely loaded
      } else {
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
      }
      this.cordova.getActivity().startActivity(intent);
      return "";
    } catch (android.content.ActivityNotFoundException e) {
      Log.d(LOG_TAG, "ChildBrowser: Error loading url " + url + ":" + e.toString());
      return e.toString();
    }
  }
Ejemplo n.º 13
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
      // add it to the Gallery

      if (requestCode == PICK_PHOTO_REQUEST || requestCode == PICK_VIDEO_REQUEST) {
        if (data == null) {
          Toast.makeText(this, R.string.general_error, Toast.LENGTH_SHORT).show();
        } else {
          mMediaUri = data.getData();
        }

        Log.i(TAG, "Media URI: " + mMediaUri);
        if (requestCode == PICK_VIDEO_REQUEST) {
          // Make sure the file is less than 10 MB
          int fileSize = 0;
          InputStream inputStream = null;
          try {
            inputStream = getContentResolver().openInputStream(mMediaUri);
            fileSize = inputStream.available();
          } catch (IOException e) {
            Toast.makeText(this, R.string.error_opening_file, Toast.LENGTH_SHORT).show();
            return;
          } finally {
            try {
              inputStream.close();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }

          if (fileSize >= FILE_SIZE_LIMIT) {
            Toast.makeText(this, R.string.error_file_size_too_large, Toast.LENGTH_SHORT).show();
            return;
          }
        }
      } else {
        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        mediaScanIntent.setData(mMediaUri);
        sendBroadcast(mediaScanIntent);
      }

      Intent recipientsIntent = new Intent(this, RecipientsActivity.class);
      recipientsIntent.setData(mMediaUri);
      String fileType;
      if (requestCode == PICK_PHOTO_REQUEST || requestCode == TAKE_PHOTO_REQUEST) {
        fileType = ParseConstants.TYPE_IMAGE;
      } else {
        fileType = ParseConstants.TYPE_VIDEO;
      }
      recipientsIntent.putExtra(ParseConstants.KEY_FILE_TYPE, fileType);
      startActivity(recipientsIntent);

    } else if (resultCode != RESULT_CANCELED) {
      Toast.makeText(this, R.string.general_error, Toast.LENGTH_LONG).show();
    }
  }
 /** View contact that has the message address (or create if it doesn't exist) */
 private void viewContact() {
   Intent contactIntent = new Intent(Contacts.Intents.SHOW_OR_CREATE_CONTACT);
   if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_MMS || message.isEmail()) {
     contactIntent.setData(Uri.fromParts("mailto", message.getAddress(), null));
   } else {
     contactIntent.setData(Uri.fromParts("tel", message.getAddress(), null));
   }
   startActivity(contactIntent);
 }
  /**
   * Load the specified URL in the Cordova webview or a new browser instance.
   *
   * <p>NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
   *
   * @param url The url to load.
   * @param openExternal Load url in browser instead of Cordova webview.
   * @param clearHistory Clear the history stack, so new page becomes top of history
   * @param params DroidGap parameters for new app
   */
  public void showWebPage(
      String url,
      boolean openExternal,
      boolean clearHistory,
      HashMap<String, Object> params) { // throws android.content.ActivityNotFoundException {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
      this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

      // Make sure url is in whitelist
      if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || isUrlWhiteListed(url)) {
        // TODO: What about params?

        // Clear out current url from history, since it will be replacing it
        if (clearHistory) {
          this.urls.clear();
        }

        // Load new URL
        this.loadUrl(url);
      }
      // Load in default viewer if not
      else {
        LOG.w(
            TAG,
            "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL="
                + url
                + ")");
        try {
          Intent intent = new Intent(Intent.ACTION_VIEW);
          intent.setData(Uri.parse(url));
          this.startActivity(intent);
        } catch (android.content.ActivityNotFoundException e) {
          LOG.e(TAG, "Error loading url " + url, e);
        }
      }
    }

    // Load in default view intent
    else {
      try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        this.startActivity(intent);
      } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
      }
    }
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
      case R.id.share:
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody =
            "Hey check swatch hubli app at playstore https://play.google.com/store/apps/details?id=practicalcoding.swatchbharat.main it was built by BVBCET students";
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Swatch bharat app");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, "Tell your friends"));
        return true;
      case R.id.like:
        Intent browserIntent =
            new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/PracticalCoding"));
        startActivity(browserIntent);
        return true;
      case R.id.rate:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=practicalcoding.swatchbharat.main"));
        startActivity(intent);
        return true;
      case R.id.feedback:
        String[] TO = {"*****@*****.**"};
        String[] CC = {
          "[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]"
        };
        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setData(Uri.parse("mailto:"));
        emailIntent.setType("text/plain");

        emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
        emailIntent.putExtra(Intent.EXTRA_CC, CC);
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback of Swatch Hubli app");
        emailIntent.putExtra(Intent.EXTRA_TEXT, "");

        try {
          startActivity(Intent.createChooser(emailIntent, "Send mail..."));
          finish();
          Log.i("Finished sending email...", "");
        } catch (android.content.ActivityNotFoundException ex) {
          Toast.makeText(
                  getApplicationContext(),
                  "There is no email client installed.",
                  Toast.LENGTH_SHORT)
              .show();
        }

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Ejemplo n.º 17
0
 public void review(View view) {
   Intent i = new Intent(Intent.ACTION_VIEW);
   // Error catching: If Google Play app is not installed, open with browser instead
   try {
     // i.setData(Uri.parse("market://details?id=" + url));
     i.setData(Uri.parse("http://foodfriends92.wix.com/index"));
     startActivity(i);
   } catch (android.content.ActivityNotFoundException anfe) {
     i.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + url));
     startActivity(i);
   }
 }
Ejemplo n.º 18
0
 /**
  * Get a {@link Intent} for sending a new message.
  *
  * @param context {@link Context}
  * @param address address
  * @return {@link Intent}
  */
 static Intent getComposeIntent(
     final Context context, // .
     final String address) {
   final Intent i = new Intent(Intent.ACTION_SENDTO);
   i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   if (address == null) {
     i.setData(Uri.parse("sms:"));
   } else {
     i.setData(Uri.parse("smsto:" + PreferencesActivity.fixNumber(context, address)));
   }
   return i;
 }
Ejemplo n.º 19
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case 0:
        Intent ligar = new Intent(Intent.ACTION_CALL);
        ligar.setData(Uri.parse("tel:" + alunoSelecionado.getTelefone()));
        startActivity(ligar);
        break;
      case 1:
        Intent sms = new Intent(Intent.ACTION_VIEW);
        sms.setData(Uri.parse("sms:" + alunoSelecionado.getTelefone()));
        sms.putExtra("sms_body", "corpo da mensagem.");
        startActivity(sms);
        break;
      case 2:
        Intent mapa = new Intent(Intent.ACTION_VIEW);
        mapa.setData(Uri.parse("geo:0,0?z=14&q=" + alunoSelecionado.getEndereco()));
        startActivity(mapa);
        break;
      case 3:
        Intent site = new Intent(Intent.ACTION_VIEW);
        String url = alunoSelecionado.getSite();
        if (url.substring(0, 7).equals("http://")) {
          site.setData(Uri.parse(url));
        } else {
          site.setData(Uri.parse("http://" + url));
        }
        startActivity(site);
        break;
      case 4:
        AlunoDao dao = new AlunoDao(this);
        dao.deletar(alunoSelecionado);
        dao.close();
        carregaLista();
        break;
      default:
        break;
    }

    // if(item.getItemId() == 4)
    // {
    //	AlunoDao dao = new AlunoDao(this);
    //	dao.deletar(alunoSelecionado);
    //	dao.close();
    //	carregaLista();
    // }

    return super.onContextItemSelected(item);
  }
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    ComponentName thisWidget = new ComponentName(context, Widget4x4Provider.class);
    this.appWidgetIds = appWidgetIds;

    /*
    Set up the intent that starts the LargeWidgetService, which will
    provide the views for this collection.
    */
    Intent serviceIntent = new Intent(context, LargeWidgetService.class);

    // ---Add this app widget to the intent extras---
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, thisWidget);
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));

    /*
    This adapter connects to a RemoteViewsService through the specified intent.
    This is how you populate the data.
    */
    remoteView =
        new RemoteViews(
            context.getPackageName(), com.eazyigz.RussiaMediaSearch.R.layout.appwidget_4x4);
    //        remoteView.setRemoteAdapter(R.id.listViewWidget, serviceIntent);
    for (int i = 0; i < appWidgetManager.getAppWidgetIds(thisWidget).length; ++i) {
      remoteView.setRemoteAdapter(
          appWidgetManager.getAppWidgetIds(thisWidget)[i], R.id.listViewWidget, serviceIntent);
    }
    remoteView.setEmptyView(R.id.listViewWidget, R.id.row_empty_label_widget);

    final Intent onClickIntent = new Intent(context, Widget4x4Provider.class);
    onClickIntent.setAction(Widget4x4Provider._listClickAction);
    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
    final PendingIntent listClickPendingIntent =
        PendingIntent.getBroadcast(context, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      remoteView.setPendingIntentTemplate(R.id.listViewWidget, listClickPendingIntent);

    setupLauncherShortcut(context, remoteView);
    setupRussianVoiceSearch(context, remoteView);
    setupEnglishVoiceSearch(context, remoteView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      appWidgetManager.notifyAppWidgetViewDataChanged(
          appWidgetManager.getAppWidgetIds(thisWidget), R.id.listViewWidget);
    appWidgetManager.updateAppWidget(thisWidget, remoteView);

    super.onUpdate(context, appWidgetManager, appWidgetManager.getAppWidgetIds(thisWidget));
  }
 private static void openStorePageInternat(Context context, String packageName) {
   Intent intent = new Intent(Intent.ACTION_VIEW);
   switch (FahrschulePreferences.getInstance().getApplicationStore()) {
     case ANDROIDPIT:
       intent.setData(Uri.parse("appcenter://package/" + packageName));
       try {
         context.startActivity(intent);
       } catch (ActivityNotFoundException ex) {
         Utils.createDialog(
             context,
             context.getString(R.string.androidpit_not_installed),
             context.getString(R.string.androidpit_not_installed_desc));
       }
       break;
     case MARKET:
       intent.setData(Uri.parse("market://details?id=" + packageName));
       try {
         context.startActivity(intent);
       } catch (ActivityNotFoundException ex) {
         Utils.createDialog(
             context,
             context.getString(R.string.market_not_installed),
             context.getString(R.string.market_not_installed_desc));
       }
       break;
     case SAMSUNG_APPS:
       intent.setData(Uri.parse("samsungapps://ProductDetail/" + packageName));
       try {
         context.startActivity(intent);
       } catch (ActivityNotFoundException ex) {
         Utils.createDialog(
             context,
             context.getString(R.string.samsungapps_not_installed),
             context.getString(R.string.samsungapps_not_installed_desc));
       }
       break;
     case AMAZON:
       intent.setData(Uri.parse("amzn://apps/android?p=" + packageName));
       try {
         context.startActivity(intent);
       } catch (ActivityNotFoundException ex) {
         Utils.createDialog(
             context,
             context.getString(R.string.amazon_not_installed),
             context.getString(R.string.amazon_not_installed_desc));
       }
       break;
   }
 }
Ejemplo n.º 22
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {

    AdapterView.AdapterContextMenuInfo menuInfo =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int arrayAdapterPosition = menuInfo.position;
    ContactDetails selectedContact = contactsAdapter.getItem(arrayAdapterPosition);
    String number = selectedContact.getPhoneNumber();
    Intent callIntent;
    int id = item.getItemId();
    switch (id) {
      case 1001:
        Log.d("MainActivity", "Call option is selected");
        callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + number));

        /*if (checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    public void requestPermissions(@NonNull String[] permissions, int requestCode)
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for Activity#requestPermissions for more details.
            return false;
        }*/
        try {
          startActivity(callIntent);
        } catch (Exception e) {
          Log.e("Exception", e.getMessage());
        }
        break;
      case 1002:
        Log.d("MainActivity", "SMS option is selected");
        callIntent = new Intent(Intent.ACTION_SENDTO);
        callIntent.addCategory(Intent.CATEGORY_DEFAULT);
        callIntent.setType("vnd.android-dir/mms-sms");
        callIntent.setData(Uri.parse("sms:" + number));
        try {
          startActivity(callIntent);
        } catch (Exception e) {
          Log.e("Exception", e.getMessage());
        }
        break;
    }

    return true;
  }
 public void btnCallUsClicked(View view) {
   // open dialer and pass their number
   String novMaxNumber = "+447540595289";
   Intent i = new Intent(Intent.ACTION_CALL);
   i.setData(Uri.parse("tel:" + novMaxNumber));
   startActivity(i);
 }
  @Override
  public void onClick(View v) {
    if (entry == null) {
      return;
    }

    switch (entry.getState()) {
      case ThemeEntry.STATE_UNINSTALLED:
        Uri uri = Uri.parse("market://search?q=pname:" + entry.getPackageName());
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        try {
          v.getContext().startActivity(intent);
        } catch (ActivityNotFoundException e) {
          uri = Uri.parse(entry.getFileUrl());
          intent.setData(uri);
          v.getContext().startActivity(intent);
        }
        break;
      case ThemeEntry.STATE_INSTALLED:
        useTheme(v.getContext());
        break;
      case ThemeEntry.STATE_USING:
        break;
    }
  }
Ejemplo n.º 25
0
 public void onMapClick(View view) {
   // Googleマップを呼び出す
   Intent intent = new Intent();
   intent.setAction(Intent.ACTION_VIEW);
   intent.setData(Uri.parse("geo:35.170667,136.881859?z=17"));
   startActivity(intent);
 }
Ejemplo n.º 26
0
 public void onBrowserClick(View view) {
   // ブラウザを呼び出す
   Intent intent = new Intent();
   intent.setAction(Intent.ACTION_VIEW);
   intent.setData(Uri.parse("http://www.google.com"));
   startActivity(intent);
 }
Ejemplo n.º 27
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    mPositions.put(mDirectory.getAbsolutePath(), getListView().getFirstVisiblePosition());

    if (position < (mParent == null ? 0 : 1)) {
      mDirectory = mParent;
      mHandler.post(mUpdateFiles);
      return;
    }

    position -= (mParent == null ? 0 : 1);

    if (position < mDirs.length) {
      mDirectory = mDirs[position];
      mHandler.post(mUpdateFiles);
      return;
    }

    position -= mDirs.length;

    Uri uri = Uri.parse(mFiles[position].getAbsolutePath());
    Intent intent = new Intent(this, MuPDFActivity.class);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(uri);
    startActivity(intent);
  }
  private void pokeGpsExploit(final HardwareCallback callback, final int index) {
    Timeout.clearTimeout(gpsEventTimeout);

    // exploit a bug in the power manager widget
    final Intent poke = new Intent();
    poke.setClassName(
        "com.android.settings",
        "com.android.settings.widget.SettingsAppWidgetProvider"); //$NON-NLS-1$//$NON-NLS-2$
    poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
    poke.setData(Uri.parse("3")); // $NON-NLS-1$
    mContext.sendBroadcast(poke);

    // sit & wait for event, otherwise trigger backup safety time-out
    gpsEventTimeout =
        Timeout.setTimeout(
            new Runnable() {
              public void run() {
                gpsEventTimeout = -1;
                unbindGps();
                callback.hardwareFailedToEnable(
                    index, HardwareCallback.REASON_GPS_TOGGLE_EXPLOIT_ATTEMPT);
              }
            },
            5000);
  }
Ejemplo n.º 29
0
  /**
   * Give the host application a chance to take over the control when a new url is about to be
   * loaded in the current WebView.
   *
   * @param view The WebView that is initiating the callback.
   * @param url The url to be loaded.
   * @return true to override, false for default behavior
   */
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
  boolean shouldOverrideUrlLoading(WebView view, String url) {
    // The WebView should support http and https when going on the Internet
    if (url.startsWith("http:") || url.startsWith("https:")) {
      // We only need to whitelist sites on the Internet!
      if (appView.getWhitelist().isUrlWhiteListed(url)) {
        return false;
      }
    }
    // Give plugins the chance to handle the url
    else if (this.appView.pluginManager.onOverrideUrlLoading(url)) {

    } else if (url.startsWith("file://") | url.startsWith("data:")) {
      // This directory on WebKit/Blink based webviews contains SQLite databases!
      // DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
      return url.contains("app_webview");
    } else {
      try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setComponent(null);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
          intent.setSelector(null);
        }
        this.cordova.getActivity().startActivity(intent);
      } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
      }
    }
    // Default behaviour should be to load the default intent, let's see what happens!
    return true;
  }
Ejemplo n.º 30
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(
        "ProfileFragment",
        "Here in onActivityResult with requestCode: "
            + requestCode
            + " , resultCode: "
            + resultCode
            + " , data: "
            + data);
    super.onActivityResult(requestCode, resultCode, data);
    //    ParseFacebookUtils.onActivityResult(requestCode, resultCode, data);

    if (resultCode == this.RESULT_OK) {
      if (requestCode == CHOOSE_PHOTO_REQUEST) {
        if (data == null) {
          Toast.makeText(this, "Sorry, there was an error", Toast.LENGTH_LONG).show();
        } else {
          mMediaUri = data.getData();
          Log.d("ProfileFragment", "Here in onActivityResult's if if else.");
          setImage(mMediaUri);
        }
      } else {
        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        mediaScanIntent.setData(mMediaUri);
        this.sendBroadcast(mediaScanIntent);
        setImage(mMediaUri);
        Log.d("ProfileFragment", "Here in onActivityResult's if else.");
      }
    } else if (resultCode != this.RESULT_CANCELED) {
      Toast.makeText(this, "Sorry, there was an error", Toast.LENGTH_LONG).show();
    }
  }