List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:com.crowflying.buildwatch.ConfigurationActivity.java
@Override public boolean onPreferenceClick(Preference preference) { Log.d(LOG_TAG, String.format("Preference %s was clicked...", preference.getKey())); // Call the code for autosetup... if (PREFS_AUTOSETUP.equals(preference.getKey())) { Log.i(LOG_TAG, "Calling XZING."); tracker.trackEvent("configuration", "subscreen", "autosetup", 0L); IntentIntegrator integrator = new IntentIntegrator(this); integrator.setMessageByID(R.string.barcode_scanner_not_installed_message); integrator.initiateScan();//from ww w . j a v a 2 s.c o m return true; } if (PREFS_FORGET_SETTINGS.equals(preference.getKey())) { Log.i(LOG_TAG, "Forgetting all settings"); tracker.trackEvent("configuration", "action", "settings_cleared", 0L); PreferenceManager.getDefaultSharedPreferences(this).edit().clear().commit(); return true; } if (PREFS_KEY_LAUNCH_WEBSITE.equals(preference.getKey())) { Log.i(LOG_TAG, "Launching website"); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(getString(R.string.config_launch_website_url))); startActivity(i); return true; } if (PREFS_KEY_GCM_TOKEN.equals(preference.getKey())) { String token = getPreferenceManager().getSharedPreferences().getString(PREFS_KEY_GCM_TOKEN, ""); if (!TextUtils.isEmpty(token)) { Log.i(LOG_TAG, "Token clicked. Echoing it to the logfile for convencience: " + token); Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.share_gcm_token_subject)); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, token); startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_gcm_token_using))); } return true; } return false; }
From source file:com.njlabs.amrita.aid.aums.AumsResourcesActivity.java
private void openFile(File file, String fileName) { Intent fileOpenIntent = new Intent(Intent.ACTION_VIEW); fileOpenIntent.setData(Uri.fromFile(file)); Intent fileChooserIntent = Intent.createChooser(fileOpenIntent, "Open " + fileName + " with:"); startActivity(fileChooserIntent);/*from w ww .jav a2 s . c o m*/ }
From source file:de.micmun.android.workdaystarget.DaysLeftService.java
/** * Updates the days to target.//from w ww . ja v a2 s .com */ private void updateDays() { AppWidgetManager appManager = AppWidgetManager.getInstance(this); ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class); int[] appIds = appManager.getAppWidgetIds(cName); DayCalculator dayCalc = new DayCalculator(); if (!isOnline()) { try { Thread.sleep(60000); } catch (InterruptedException e) { Log.e(TAG, "Interrupted: " + e.getLocalizedMessage()); } } for (int appId : appIds) { PrefManager pm = new PrefManager(this, appId); Calendar target = pm.getTarget(); boolean[] chkDays = pm.getCheckedDays(); int days = pm.getLastDiff(); if (isOnline()) { try { days = dayCalc.getDaysLeft(target.getTime(), chkDays); Map<String, Object> saveMap = new HashMap<String, Object>(); Long diff = Long.valueOf(days); saveMap.put(PrefManager.KEY_DIFF, diff); pm.save(saveMap); } catch (JSONException e) { Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage()); } } else { Log.e(TAG, "No internet connection!"); } RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String targetStr = df.format(target.getTime()); rv.setTextViewText(R.id.target, targetStr); String dayStr = String.format(Locale.getDefault(), "%d %s", days, getResources().getString(R.string.unit)); rv.setTextViewText(R.id.dayCount, dayStr); // put widget id into intent Intent configIntent = new Intent(this, ConfigActivity.class); configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent); // update widget appManager.updateAppWidget(appId, rv); } }
From source file:org.thomnichols.android.gmarks.WebViewLoginActivity.java
protected void showAuthenticatorMissingDialog() { new AlertDialog.Builder(this).setTitle(R.string.two_factor_auth_dlg_title) .setMessage(Html.fromHtml(getString(R.string.two_factor_not_installed_dlg_msg))) .setCancelable(false).setPositiveButton(R.string.btn_download, new OnClickListener() { public void onClick(DialogInterface dialog, int _) { final Intent marketActivity = new Intent(Intent.ACTION_VIEW, MARKET_URI); if (getPackageManager().resolveActivity(marketActivity, 0) == null) marketActivity.setData(MARKET_WEB_URI); try { startActivity(marketActivity); } catch (Exception ex) { Log.w(TAG, "Couldn't open Android Market for Authenticator app!!"); }//w w w .jav a2 s . c om } }).setNegativeButton(getString(R.string.btn_cancel), new OnClickListener() { public void onClick(DialogInterface dlg, int _) { dlg.dismiss(); } }).show(); }
From source file:com.groupme.sdk.GroupMeConnect.java
public void openGroupInGroupMeApp(GroupMeGroup group) { if (hasGroupMeAppInstalled()) { Intent intent = new Intent(); intent.setData(Uri.parse("groupme://group/id/" + group.getGroupId())); mContext.startActivity(intent);/* w ww .ja v a2 s .c o m*/ } }
From source file:com.groupme.sdk.GroupMeConnect.java
public void openGroupInGroupMeApp(String groupId) { if (hasGroupMeAppInstalled()) { Intent intent = new Intent(); intent.setData(Uri.parse("groupme://group/id/" + groupId)); mContext.startActivity(intent);//w w w . j av a2 s . c o m } }
From source file:com.andrewshu.android.reddit.reddits.PickSubredditActivity.java
private void returnSubreddit(String subreddit) { Intent intent = new Intent(); intent.setData(Util.createSubredditUri(subreddit)); setResult(RESULT_OK, intent);/* w w w.ja v a2 s . c o m*/ finish(); }
From source file:com.cloudkick.NodeViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.do_connectbot: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String user = prefs.getString("sshUser", "root"); Integer port = new Integer(prefs.getString("sshPort", "22")); String uri = "ssh://" + user + "@" + node.ipAddress + ":" + port + "/#" + user; Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); try {/*from w ww . ja v a 2 s . co m*/ startActivity(i); } catch (ActivityNotFoundException e) { // Suggest ConnectBot AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("SSH Client Not Found"); String mfaMessage = ("The ConnectBot SSH Client is required to complete this operation. " + "Would you like to install ConnectBot from the Android Market now?"); builder.setMessage(mfaMessage); builder.setCancelable(true); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent marketActivity = new Intent(Intent.ACTION_VIEW); marketActivity.setData(Uri.parse("market://details?id=org.connectbot")); startActivity(marketActivity); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog mfaDialog = builder.create(); mfaDialog.show(); } return true; default: // If its not recognized, do nothing return super.onOptionsItemSelected(item); } }
From source file:com.googlecode.android_scripting.activity.Main.java
protected void broadcastInstallationStateChange(boolean isInterpreterInstalled) { Intent intent = new Intent(); intent.setData(Uri.parse("package:" + mId)); if (isInterpreterInstalled) { intent.setAction(InterpreterConstants.ACTION_INTERPRETER_ADDED); } else {/* w w w.jav a 2s . c om*/ intent.setAction(InterpreterConstants.ACTION_INTERPRETER_REMOVED); } sendBroadcast(intent); }
From source file:com.andrada.sitracker.ui.fragment.AuthorsFragment.java
@Override public boolean onActionItemClicked(@NotNull ActionMode mode, @NotNull MenuItem item) { mode.finish();//from w w w .j a v a 2s. c o m if (item.getItemId() == R.id.action_remove) { AnalyticsHelper.getInstance().sendEvent(Constants.GA_ADMIN_CATEGORY, Constants.GA_EVENT_AUTHOR_REMOVED, Constants.GA_EVENT_AUTHOR_REMOVED, (long) mSelectedAuthors.size()); //This stuff is on background thread adapter.removeAuthors(mSelectedAuthors); return true; } else if (item.getItemId() == R.id.action_mark_read) { adapter.markAuthorsRead(mSelectedAuthors); AnalyticsHelper.getInstance().sendEvent(Constants.GA_ADMIN_CATEGORY, Constants.GA_EVENT_AUTHOR_MANUAL_READ, Constants.GA_EVENT_AUTHOR_MANUAL_READ, (long) mSelectedAuthors.size()); BackupManager bm = new BackupManager(getActivity()); bm.dataChanged(); return true; } else if (item.getItemId() == R.id.action_open_authors_browser) { for (int i = 0; i < adapter.getCount(); i++) { if (mSelectedAuthors.contains(adapter.getItemId(i))) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(((Author) adapter.getItem(i)).getUrl())); getActivity().startActivity(intent); } } return true; } return false; }