List of usage examples for android.content Intent ACTION_EDIT
String ACTION_EDIT
To view the source code for android.content Intent ACTION_EDIT.
Click Source Link
From source file:com.app.uafeed.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { cursor.close();/*from w ww . j a v a 2s . c om*/ Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Toast.LENGTH_LONG).show(); } else { cursor.close(); ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) { url = Constants.HTTP_SCHEME + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); } } super.onDestroy(); }
From source file:at.jclehner.rxdroid.DrugListActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, final View v, ContextMenuInfo menuInfo) { final DoseView doseView = (DoseView) v; if (toastIfPastMaxHistoryAge(doseView.getDate())) return;// ww w . java 2s .com final Drug drug = doseView.getDrug(); final int doseTime = doseView.getDoseTime(); // menu.setHeaderIcon(android.R.drawable.ic_menu_agenda); menu.setHeaderTitle(drug.getName()); // //////////////////////////////////////////////// // //////////////////////////////////////////////// final boolean wasDoseTaken = doseView.wasDoseTaken(); if (wasDoseTaken) { menu.add(0, CMENU_REMOVE_DOSE, 0, R.string._title_mark_not_taken) .setOnMenuItemClickListener(new OnContextMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { MutableFraction dose = new MutableFraction(); for (DoseEvent intake : Entries.findDoseEvents(drug, mCurrentDate, doseTime)) { dose.add(intake.getDose()); Database.delete(intake); } drug.setCurrentSupply(drug.getCurrentSupply().plus(dose)); Database.update(drug); return true; } }); } else { menu.add(0, CMENU_IGNORE_DOSE, 0, R.string._title_ignore_dose) .setOnMenuItemClickListener(new OnContextMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { Database.create(new DoseEvent(drug, doseView.getDate(), doseTime)); return true; } }); } menu.add(0, CMENU_TAKE_DOSE, 0, R.string._title_mark_taken) .setOnMenuItemClickListener(new OnContextMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { showDoseDialog(drug, doseView.getDate(), doseTime, true); return true; } }); final Intent editIntent = new Intent(this, DrugEditActivity.class); editIntent.setAction(Intent.ACTION_EDIT); editIntent.putExtra(DrugEditActivity.EXTRA_DRUG_ID, drug.getId()); menu.add(0, CMENU_EDIT_DRUG, 0, R.string._title_edit_drug).setIntent(editIntent); if (BuildConfig.DEBUG) { menu.add(0, CMENU_DUMP, 0, "Dump").setOnMenuItemClickListener(new OnContextMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, drug.getName()); return true; } }); } }
From source file:com.money.manager.ex.fragment.AccountFragment.java
/** * start the activity of transaction management * //from ww w . j av a 2s. com * @param transId * null set if you want to do a new transaction, or transaction id */ private void startCheckingAccountActivity(Integer transId) { // create intent, set Account ID Intent intent = new Intent(getActivity(), CheckingAccountActivity.class); intent.putExtra(CheckingAccountActivity.KEY_ACCOUNT_ID, mAccountId); // check transId not null if (transId != null) { intent.putExtra(CheckingAccountActivity.KEY_TRANS_ID, transId); intent.setAction(Intent.ACTION_EDIT); } else { intent.setAction(Intent.ACTION_INSERT); } // launch activity startActivity(intent); }
From source file:net.ddns.mlsoftlaberge.trycorder.contacts.ContactAdminFragment.java
private void buttonedit() { // Standard system edit contact intent Intent intent = new Intent(Intent.ACTION_EDIT, mContactUri); // Because of an issue in Android 4.0 (API level 14), clicking Done or Back in the // People app doesn't return the user to your app; instead, it displays the People // app's contact list. A workaround, introduced in Android 4.0.3 (API level 15) is // to set a special flag in the extended data for the Intent you send to the People // app. The issue is does not appear in versions prior to Android 4.0. You can use // the flag with any version of the People app; if the workaround isn't needed, // the flag is ignored. intent.putExtra("finishActivityOnSaveCompleted", true); // Start the edit activity startActivity(intent);/*from w ww. j a va 2 s. c o m*/ }
From source file:at.jclehner.rxdroid.DrugListActivity.java
public void onDrugNameClick(View view) { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setClass(this, DrugEditActivity.class); Drug drug = Drug.get((Integer) view.getTag(TAG_DRUG_ID)); intent.putExtra(DrugEditActivity.EXTRA_DRUG_ID, drug.getId()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); //startActivityForResult(intent, 0); startActivity(intent);//from w w w . j ava 2s.c o m }
From source file:com.carlrice.reader.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = null;/*w ww. jav a 2s . co m*/ try { cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor != null && cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Toast.LENGTH_LONG).show(); } else { ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) { url = Constants.HTTP_SCHEME + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); } } catch (Exception ignored) { } finally { if (cursor != null) { cursor.close(); } } } super.onDestroy(); }
From source file:org.odk.collect.android.application.Collect.java
public Intent getStartSurveyIntent(int surveyIndex) { //get the item we are on JsonObject o = (JsonObject) Surveys.get(surveyIndex); if (o != null) { StringBuilder sb = new StringBuilder(); JsonElement surveyTypeCode = o.get("SurveyTypeCode"); JsonElement address1 = o.get("address1"); JsonElement address2 = o.get("address2"); JsonElement surveynumber = o.get("surveynumber"); if (surveyTypeCode.isJsonNull() || surveyTypeCode.getAsString().length() == 0) sb.append("No Survey Type "); String address = ""; if (!address1.isJsonNull() && address1.getAsString().length() > 0) { address += address1.getAsString(); }//from www.j a v a2s.c om if (!address2.isJsonNull() && address2.getAsString().length() > 0) { address += address2.getAsString(); } if (address.length() == 0) sb.append("No Address "); if (surveynumber.isJsonNull() || surveynumber.getAsString().length() == 0) sb.append("No Survey Number Type"); if (sb.length() > 0) { Toast toast = Toast.makeText(this, sb.toString(), Toast.LENGTH_LONG); return null; } String mFormPath = getBlankFormPath(surveyTypeCode.getAsString()); if (mFormPath == null) { Toast toast = Toast.makeText(this, String.format("Could not find a Form for %s. Please Download Blank Forms.", surveyTypeCode.getAsString()), Toast.LENGTH_LONG); return null; } //find the uri of the form in the SQLLite database Uri formUri = Uri.parse(mFormPath); Intent intent = new Intent(Intent.ACTION_EDIT, formUri); intent.putExtra("flikk", o.toString()); //intent.setDataAndType(Uri.parse("vnd.android.cursor.item/vnd.odk.form"), mFormPath); //new Intent(ACTION_EDIT, // Uri.parse(FormsProviderAPI.FormsColumns.FLIKK_SURVEY_TYPE)) //startActivity(intent); return intent; } return null; }
From source file:net.fred.feedex.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = null;//from w w w . jav a2s .c om try { cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor != null && cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { UiUtils.showMessage(EditFeedActivity.this, R.string.error_feed_url_exists); } else { ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) { url = Constants.HTTP_SCHEME + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); } } catch (Exception ignored) { } finally { if (cursor != null) { cursor.close(); } } } super.onDestroy(); }
From source file:org.openintents.notepad.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (DEBUG) {/* w ww. ja v a 2 s. co m*/ Log.d(TAG, "onCreate()"); } if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) { createShortcut(); return; } if (savedInstanceState == null) { // sDecryptedText has no use for brand new activities sDecryptedText = null; } // Usually, sDecryptedText == null. mDecryptedText = sDecryptedText; if (sDecryptedText != null) { // we use the text right now, // so don't encrypt the text anymore. EncryptActivity.cancelEncrypt(); if (EncryptActivity.getPendingEncryptActivities() == 0) { if (DEBUG) { Log.d(TAG, "sDecryptedText = null"); } // no more encrypt activies will be called sDecryptedText = null; } } mSelectionStart = 0; mSelectionStop = 0; // If an instance of this activity had previously stopped, we can // get the original text it started with. if (savedInstanceState != null) { mOriginalContent = savedInstanceState.getString(BUNDLE_ORIGINAL_CONTENT); mUndoRevert = savedInstanceState.getString(BUNDLE_UNDO_REVERT); mState = savedInstanceState.getInt(BUNDLE_STATE); String uriString = savedInstanceState.getString(BUNDLE_URI); if (uriString != null) { mUri = Uri.parse(uriString); } mSelectionStart = savedInstanceState.getInt(BUNDLE_SELECTION_START); mSelectionStop = savedInstanceState.getInt(BUNDLE_SELECTION_STOP); mFileContent = savedInstanceState.getString(BUNDLE_FILE_CONTENT); if (mApplyText == null && mApplyTextBefore == null && mApplyTextAfter == null) { // Only read values if they had not been set by // onActivityResult() yet: mApplyText = savedInstanceState.getString(BUNDLE_APPLY_TEXT); mApplyTextBefore = savedInstanceState.getString(BUNDLE_APPLY_TEXT_BEFORE); mApplyTextAfter = savedInstanceState.getString(BUNDLE_APPLY_TEXT_AFTER); } } else { // Do some setup based on the action being performed. final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_EDIT.equals(action) || Intent.ACTION_VIEW.equals(action)) { // Requested to edit: set that state, and the data being edited. mState = STATE_EDIT; mUri = intent.getData(); if (mUri != null && mUri.getScheme().equals("file")) { mState = STATE_EDIT_NOTE_FROM_SDCARD; // Load the file into a new note. if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { mFileContent = readFile(FileUriUtils.getFile(mUri)); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_CODE_PERMISSION_READ_EXTERNAL_STORAGE); mFileContent = getString(R.string.request_permissions); } } } else if (mUri != null && !mUri.getAuthority().equals(NotePad.AUTHORITY)) { // Note a notepad note. Treat slightly differently. // (E.g. a note from OI Shopping List) mState = STATE_EDIT_EXTERNAL_NOTE; } } else if (Intent.ACTION_INSERT.equals(action) || Intent.ACTION_SEND.equals(action)) { // Use theme of most recently modified note: ContentValues values = new ContentValues(1); String theme = getMostRecentlyUsedTheme(); values.put(Notes.THEME, theme); String tags = intent.getStringExtra(NotepadInternalIntents.EXTRA_TAGS); values.put(Notes.TAGS, tags); if (mText != null) { values.put(Notes.SELECTION_START, mText.getSelectionStart()); values.put(Notes.SELECTION_END, mText.getSelectionEnd()); } // Requested to insert: set that state, and create a new entry // in the container. mState = STATE_INSERT; /* * intent.setAction(Intent.ACTION_EDIT); intent.setData(mUri); * setIntent(intent); */ if (Intent.ACTION_SEND.equals(action)) { values.put(Notes.NOTE, getIntent().getStringExtra(Intent.EXTRA_TEXT)); mUri = getContentResolver().insert(Notes.CONTENT_URI, values); } else { mUri = getContentResolver().insert(intent.getData(), values); } // If we were unable to create a new note, then just finish // this activity. A RESULT_CANCELED will be sent back to the // original activity if they requested a result. if (mUri == null) { Log.e(TAG, "Failed to insert new note into " + getIntent().getData()); finish(); return; } // The new entry was created, so assume all will end well and // set the result to be returned. // setResult(RESULT_OK, (new // Intent()).setAction(mUri.toString())); setResult(RESULT_OK, intent); } else { // Whoops, unknown action! Bail. Log.e(TAG, "Unknown action, exiting"); finish(); return; } } // setup actionbar if (mActionBarAvailable) { requestWindowFeature(Window.FEATURE_ACTION_BAR); WrapActionBar bar = new WrapActionBar(this); bar.setDisplayHomeAsUpEnabled(true); // force to show the actionbar on version 14+ if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 14) { bar.setHomeButtonEnabled(true); } } else { requestWindowFeature(Window.FEATURE_RIGHT_ICON); } // Set the layout for this activity. You can find it in // res/layout/note_editor.xml setContentView(R.layout.note_editor); // The text view for our note, identified by its ID in the XML file. mText = (EditText) findViewById(R.id.note); if (mState == STATE_EDIT_NOTE_FROM_SDCARD) { // We add a text watcher, so that the title can be updated // to indicate a small "*" if modified. mText.addTextChangedListener(mTextWatcherSdCard); } if (mState != STATE_EDIT_NOTE_FROM_SDCARD) { // Check if we load a note from notepad or from some external module if (mState == STATE_EDIT_EXTERNAL_NOTE) { // Get all the columns as we don't know which columns are // supported. mCursor = managedQuery(mUri, null, null, null, null); // Now check which columns are available List<String> columnNames = Arrays.asList(mCursor.getColumnNames()); if (!columnNames.contains(Notes.NOTE)) { hasNoteColumn = false; } if (!columnNames.contains(Notes.TAGS)) { hasTagsColumn = false; } if (!columnNames.contains(Notes.ENCRYPTED)) { hasEncryptionColumn = false; } if (!columnNames.contains(Notes.THEME)) { hasThemeColumn = false; } if (!columnNames.contains(Notes.SELECTION_START)) { hasSelection_startColumn = false; } if (!columnNames.contains(Notes.SELECTION_END)) { hasSelection_endColumn = false; } } else { // Get the note! mCursor = managedQuery(mUri, PROJECTION, null, null, null); // It's not an external note, so all the columns are available // in the database } } else { mCursor = null; } mText.addTextChangedListener(mTextWatcherCharCount); initSearchPanel(); }
From source file:com.nononsenseapps.notepad.ActivityMain.java
/** * Returns a list id from an intent if it contains one, either as part of * its URI or as an extra//from w w w . j av a 2s . co m * <p/> * Returns -1 if no id was contained, this includes insert actions */ long getListId(final Intent intent) { long retval = -1; if (intent != null && intent.getData() != null && (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction()) || Intent.ACTION_INSERT.equals(intent.getAction()))) { if ((intent.getData().getPath().startsWith(NotePad.Lists.PATH_VISIBLE_LISTS) || intent.getData().getPath().startsWith(NotePad.Lists.PATH_LISTS) || intent.getData().getPath().startsWith(TaskList.URI.getPath()))) { try { retval = Long.parseLong(intent.getData().getLastPathSegment()); } catch (NumberFormatException e) { retval = -1; } } else if (-1 != intent.getLongExtra(LegacyDBHelper.NotePad.Notes.COLUMN_NAME_LIST, -1)) { retval = intent.getLongExtra(LegacyDBHelper.NotePad.Notes.COLUMN_NAME_LIST, -1); } else if (-1 != intent.getLongExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, -1)) { retval = intent.getLongExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, -1); } else if (-1 != intent.getLongExtra(Task.Columns.DBLIST, -1)) { retval = intent.getLongExtra(Task.Columns.DBLIST, -1); } } return retval; }