Example usage for android.content Intent ACTION_EDIT

List of usage examples for android.content Intent ACTION_EDIT

Introduction

In this page you can find the example usage for android.content Intent ACTION_EDIT.

Prototype

String ACTION_EDIT

To view the source code for android.content Intent ACTION_EDIT.

Click Source Link

Document

Activity Action: Provide explicit editable access to the given data.

Usage

From source file:bander.notepad.NoteListAppCompat.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {//from www.  j av a2  s . c  om
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        return;
    }

    Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
    if (cursor == null) {
        return;
    }

    menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));

    Uri uri = ContentUris.withAppendedId(getIntent().getData(), cursor.getInt(COLUMN_INDEX_ID));

    Intent[] specifics = new Intent[1];
    specifics[0] = new Intent(Intent.ACTION_EDIT, uri);
    MenuItem[] items = new MenuItem[1];

    Intent intent = new Intent(null, uri);
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0, items);

    menu.add(0, DELETE_ID, 0, R.string.menu_delete);
    // TODO: When you click on this, it crashes. I commented it out for now.
    // menu.add(0, SEND_ID, 0, R.string.menu_send);
}

From source file:com.vmihalachi.turboeditor.activity.HomeActivity.java

/**
 * When a file is saved/*  w  w  w  .j a  v  a 2s. c  o m*/
 * Invoked by the EditorFragment
 *
 * @param event The event called
 */
public void onEvent(FileSavedEvent event) {
    try {
        closeKeyBoard();
    } catch (NullPointerException e) {
        Log.e(TAG, e.getMessage(), e);
    }
    // Get intent, action and MIME type
    final Intent intent = getIntent();
    final String action = intent.getAction();
    final String type = intent.getType();

    if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action)
            || Intent.ACTION_PICK.equals(action) && type != null) {
        //This Activity was called by startActivityForResult
        final Intent returnIntent = new Intent();
        setResult(Activity.RESULT_OK, returnIntent);
        // finish the activity
        finish();
    } else {
        //This Activity was called by startActivity
        //
        mDrawerLayout.openDrawer(Gravity.LEFT);
        //
        getActionBar().setTitle(getString(R.string.nome_app_turbo_editor));
        // Replace fragment
        getFragmentManager().beginTransaction().replace(R.id.fragment_editor, new NoFileOpenedFragment())
                .commit();
    }
}

From source file:de.amuttsch.ioweu.app.ui.DebtListsActivity.java

@Override
public void onDebtSelected(int debtId) {
    Intent intent = new Intent(this, DebtEditorActivity.class);
    intent.setAction(Intent.ACTION_EDIT);
    intent.putExtra(DebtEditorActivity.EXTRA_DEBT_ID, debtId);
    startActivity(intent);/* w  w w  .  ja v a 2 s  . co m*/
}

From source file:com.microsoft.rightsmanagement.sampleapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // instantiate/get reference on retain-able Fragment instance which hold IAsyncTask
    FragmentManager fragmentManager = getSupportFragmentManager();
    mMsipcTaskFragment = (MsipcTaskFragment) fragmentManager.findFragmentByTag(MsipcTaskFragment.TAG);
    // If the Fragment is not null then it is retained across a configuration change.
    if (mMsipcTaskFragment == null) {
        mMsipcTaskFragment = new MsipcTaskFragment();
        fragmentManager.beginTransaction().add(mMsipcTaskFragment, MsipcTaskFragment.TAG).commit();
    }/*  w  w  w.  j  ava  2s .  c o m*/
    mTextEditorFragment = (TextEditorFragment) getSupportFragmentManager()
            .findFragmentByTag(TextEditorFragment.TAG);
    if (savedInstanceState == null) {
        // handle incoming intent
        Intent incommingIntent = getIntent();
        String action = incommingIntent.getAction();
        if ((action.compareTo(Intent.ACTION_VIEW) == 0) || (action.compareTo(Intent.ACTION_EDIT) == 0)) {
            // Application state doesn't exist. intent is view.
            mUriOfFilePendingConsumption = incommingIntent.getData();
        } else if (action.compareTo(Intent.ACTION_MAIN) == 0) {
            // Show Log dialog only on first launch
            showCustomerExperienceDataConsentDialogFragmentIfNeeded(new CompletionCallback<Void>() {

                @Override
                public void onSuccess(Void item) {
                    setToShowCustomerExperienceDataConsentDialogFragmentAgainOnStart(false);
                }

                @Override
                public void onCancel() {
                    setToShowCustomerExperienceDataConsentDialogFragmentAgainOnStart(true);
                    finish();
                }
            });
            createTextEditorFragment(TextEditorMode.NotEnforced, null);
        } else {
            throw new RuntimeException("shouldn't reach here");
        }
    }
}

From source file:nerd.tuxmobil.fahrplan.congress.FahrplanMisc.java

@SuppressLint("NewApi")
public static void addToCalender(Context context, Lecture l) {
    Intent intent = new Intent(Intent.ACTION_INSERT, CalendarContract.Events.CONTENT_URI);

    intent.putExtra(CalendarContract.Events.TITLE, l.title);
    intent.putExtra(CalendarContract.Events.EVENT_LOCATION, l.room);

    long when;/* w  w  w  .ja va 2 s .com*/
    if (l.dateUTC > 0) {
        when = l.dateUTC;
    } else {
        Time time = l.getTime();
        when = time.normalize(true);
    }
    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, when);
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, when + (l.duration * 60000));
    final String description = getCalendarDescription(context, l);
    intent.putExtra(CalendarContract.Events.DESCRIPTION, description);
    try {
        context.startActivity(intent);
        return;
    } catch (ActivityNotFoundException e) {
    }
    intent.setAction(Intent.ACTION_EDIT);
    try {
        context.startActivity(intent);
        return;
    } catch (ActivityNotFoundException e) {
        Toast.makeText(context, R.string.add_to_calendar_failed, Toast.LENGTH_LONG).show();
    }
}

From source file:com.nerderylabs.android.nerdalert.ui.fragment.MainFragment.java

private void initializeNametag() {
    final EditText nameEditText = (EditText) view.findViewById(R.id.my_name);
    final EditText taglineEditText = (EditText) view.findViewById(R.id.my_tagline);
    final ImageView photoImageView = (ImageView) view.findViewById(R.id.my_photo);

    // restore state
    nameEditText.setText(myInfo.getName());
    taglineEditText.setText(myInfo.getTagline());
    if (myInfo.getBitmap() != null) {
        photoImageView.setImageDrawable(new BitmapDrawable(getResources(), myInfo.getBitmap()));
    } else {//w  w  w  .ja v  a2 s. c o m
        Drawable photo = ContextCompat.getDrawable(getContext(), R.drawable.ic_contact_photo);
        DrawableCompat.setTint(photo, ContextCompat.getColor(getContext(), R.color.color_nametag));
        photoImageView.setImageDrawable(photo);
    }

    // listen for focus change
    View.OnFocusChangeListener focusListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                persistNametagValues((TextView) v);
            }
        }
    };

    // listen for the done key
    EditText.OnEditorActionListener doneListener = new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                persistNametagValues(v);
            }
            return false;
        }
    };

    // open profile contact card when user's photo is tapped
    ImageView.OnClickListener imageClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_EDIT);
            intent.setDataAndType(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.CONTENT_ITEM_TYPE);

            // In Android 4.0 (API version 14) and later, a problem in the contacts app causes
            // incorrect navigation.To work around this problem in Android 4.0.3 (API version
            // 15) and later, add the extended data key finishActivityOnSaveCompleted to the
            // intent, with a value of true.
            intent.putExtra("finishActivityOnSaveCompleted", true);

            startActivity(intent);
        }
    };

    nameEditText.setOnEditorActionListener(doneListener);
    taglineEditText.setOnEditorActionListener(doneListener);

    nameEditText.setOnFocusChangeListener(focusListener);
    taglineEditText.setOnFocusChangeListener(focusListener);

    photoImageView.setOnClickListener(imageClickListener);

}

From source file:cn.edu.nju.dapenti.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();// ww  w  . j a  v  a  2 s.  c  o  m
            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) && !url.startsWith(Constants.HTTPS)) {
                url = Constants.HTTP + 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);
            if (!name.equals(mPreviousName)) {
                cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
                cr.notifyChange(FeedColumns.GROUPED_FEEDS_CONTENT_URI, null);
            }
        }
    }

    super.onDestroy();
}

From source file:co.nerdart.ourss.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 w  w  . j  ava 2s  .com*/
            //Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists,
            //      Toast.LENGTH_LONG).show();
            Crouton.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Style.INFO);
        } else {
            cursor.close();
            ContentValues values = new ContentValues();

            if (!url.startsWith(Constants.HTTP) && !url.startsWith(Constants.HTTPS)) {
                url = Constants.HTTP + 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);
            if (!name.equals(mPreviousName)) {
                cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
            }
        }
    }

    super.onDestroy();
}

From source file:com.android.music.PlaylistBrowserFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    View view = inflater.inflate(R.layout.media_picker_activity, null);

    final Intent intent = getActivity().getIntent();
    final String action = intent.getAction();
    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
        mCreateShortcut = true;/* w w w  .  j a  v a  2s. com*/
    }

    getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mToken = MusicUtils.bindToService(getActivity(), new ServiceConnection() {
        public void onServiceConnected(ComponentName classname, IBinder obj) {
            if (Intent.ACTION_VIEW.equals(action)) {
                Bundle b = intent.getExtras();
                if (b == null) {
                    Log.w(TAG, "Unexpected:getExtras() returns null.");
                } else {
                    try {
                        long id = Long.parseLong(b.getString("playlist"));
                        if (id == RECENTLY_ADDED_PLAYLIST) {
                            playRecentlyAdded();
                        } else if (id == PODCASTS_PLAYLIST) {
                            playPodcasts();
                        } else if (id == ALL_SONGS_PLAYLIST) {
                            long[] list = MusicUtils.getAllSongs(getActivity());
                            if (list != null) {
                                MusicUtils.playAll(getActivity(), list, 0);
                            }
                        } else {
                            MusicUtils.playPlaylist(getActivity(), id);
                        }
                    } catch (NumberFormatException e) {
                        Log.w(TAG, "Playlist id missing or broken");
                    }
                }
                getActivity().finish();
                return;
            }
            MusicUtils.updateNowPlaying(getActivity());
        }

        public void onServiceDisconnected(ComponentName classname) {
        }

    });

    IntentFilter f = new IntentFilter();
    f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
    f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
    f.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    f.addDataScheme("file");
    getActivity().registerReceiver(mScanListener, f);

    lv = (ListView) view.findViewById(android.R.id.list);
    lv.setOnCreateContextMenuListener(this);
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            if (mCreateShortcut) {
                final Intent shortcut = new Intent();
                shortcut.setAction(Intent.ACTION_VIEW);
                shortcut.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/playlist");
                shortcut.putExtra("playlist", String.valueOf(id));

                final Intent intent = new Intent();
                intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut);
                intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                        ((TextView) view.findViewById(R.id.line1)).getText());
                intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource
                        .fromContext(getActivity(), R.drawable.ic_launcher_shortcut_music_playlist));

                getActivity().setResult(getActivity().RESULT_OK, intent);
                getActivity().finish();
                return;
            }
            if (id == RECENTLY_ADDED_PLAYLIST) {
                Intent intent = new Intent(Intent.ACTION_PICK);
                intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
                intent.putExtra("playlist", "recentlyadded");
                startActivity(intent);
            } else if (id == PODCASTS_PLAYLIST) {
                Intent intent = new Intent(Intent.ACTION_PICK);
                intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
                intent.putExtra("playlist", "podcasts");
                startActivity(intent);
            } else {
                Intent intent = new Intent(Intent.ACTION_EDIT);
                intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
                intent.putExtra("playlist", Long.valueOf(id).toString());
                startActivity(intent);
            }

        }
    });

    mAdapter = (PlaylistListAdapter) getActivity().getLastNonConfigurationInstance();
    if (mAdapter == null) {
        //Log.i("@@@", "starting query");
        mAdapter = new PlaylistListAdapter(getActivity().getApplication(), this, R.layout.track_list_item,
                mPlaylistCursor, new String[] { MediaStore.Audio.Playlists.NAME },
                new int[] { android.R.id.text1 });
        lv.setAdapter(mAdapter);
        //setTitle(R.string.working_playlists);
        getPlaylistCursor(mAdapter.getQueryHandler(), null);
    } else {
        mAdapter.setActivity(this);
        lv.setAdapter(mAdapter);
        mPlaylistCursor = mAdapter.getCursor();
        // If mPlaylistCursor is null, this can be because it doesn't have
        // a cursor yet (because the initial query that sets its cursor
        // is still in progress), or because the query failed.
        // In order to not flash the error dialog at the user for the
        // first case, simply retry the query when the cursor is null.
        // Worst case, we end up doing the same query twice.
        if (mPlaylistCursor != null) {
            init(mPlaylistCursor);
        } else {
            //setTitle(R.string.working_playlists);
            getPlaylistCursor(mAdapter.getQueryHandler(), null);
        }
    }

    return view;
}

From source file:com.bangz.shotrecorder.MainActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Uri uri = ContentUris.withAppendedId(ShotRecord.ShotRecords.CONTENT_URI, id);
    Intent intent = new Intent(Intent.ACTION_EDIT, uri);
    startActivity(intent);/*from w ww . j  a v a  2  s .  c o m*/

}