List of usage examples for android.content Intent ACTION_INSERT
String ACTION_INSERT
To view the source code for android.content Intent ACTION_INSERT.
Click Source Link
From source file:pl.selvin.android.listsyncsample.ui.ListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.ui_menu_newitem: if (listID != null) { Intent intent = new Intent(Intent.ACTION_INSERT, null, getActivity(), EditItemActivity.class); intent.putExtra(Item.LISTID, listID); startActivity(intent);//from w w w . j a v a2 s . c o m } else { Toast.makeText(getActivity(), "Can't add new item to unsaved list!", Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_feed_edit); setResult(RESULT_CANCELED);// ww w . ja va2 s . co m Intent intent = getIntent(); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View filtersLayout = findViewById(R.id.filters_layout); View buttonLayout = findViewById(R.id.button_layout); if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); filtersLayout.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } restoreInstanceState(savedInstanceState); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (!restoreInstanceState(savedInstanceState)) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } } } }
From source file:org.dmfs.tasks.model.Model.java
public boolean hasInsertActivity() { if (mSupportsInsertListIntent == null) { ComponentName insertComponent = getListIntent(mContext, Intent.ACTION_INSERT, null) .resolveActivity(mContext.getPackageManager()); mSupportsInsertListIntent = insertComponent != null; }/*ww w.ja va 2 s . com*/ return mSupportsInsertListIntent; }
From source file:co.nerdart.ourss.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.feed_edit);//from ww w. j a v a 2 s . c om setResult(RESULT_CANCELED); Intent intent = getIntent(); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View filtersLayout = findViewById(R.id.filters_layout); View buttonLayout = findViewById(R.id.button_layout); if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); filtersLayout.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } restoreInstanceState(savedInstanceState); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (!restoreInstanceState(savedInstanceState)) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO); finish(); } } } }
From source file:bander.notepad.NoteListAppCompat.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.INSERT_ID: startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData()) .setClassName(getApplicationContext().getPackageName(), "bander.notepad.NoteEditAppCompat")); return true; case R.id.SEARCH_ID: onSearchRequested();//from w w w . ja v a2 s. c om return true; case R.id.PREFS_ID: { Intent prefsActivity = new Intent(this, PrefsActivityAppCompat.class); startActivity(prefsActivity); finish(); } return true; } return super.onOptionsItemSelected(item); }
From source file:dev.drsoran.moloko.activities.TaskEditActivity.java
private void createIntentDependentFragment() { final String action = getIntent().getAction(); if (Intent.ACTION_EDIT.equals(action)) { addFragment(TaskEditFragment.class); } else if (Intent.ACTION_INSERT.equals(action)) { addFragment(TaskAddFragment.class); } else {/*from ww w . ja v a2 s . c o m*/ throw new UnsupportedOperationException( String.format("Intent action unhandled: %s", getIntent().getAction())); } }
From source file:com.example.android.notepad.NotesList.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_ITEM_INSERT: // Launch activity to insert a new item startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData())); return true; case MENU_ITEM_REFRESH: // Ilya: added a refresh button // Perform a managed query. The Activity will handle closing and requerying the cursor // when needed. Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null, Notes.DEFAULT_SORT_ORDER); // Used to map notes entries from the database to views SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor, new String[] { Notes.TITLE }, new int[] { android.R.id.text1 }); setListAdapter(adapter);/*from ww w.ja v a2 s .co m*/ return true; } return super.onOptionsItemSelected(item); }
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;//from w w w . j a v a 2 s .c o m 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:dev.dworks.apps.asecure.MainActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.register: Intent i = new Intent(this, SIMAddEditActivity.class); i.setAction(Intent.ACTION_INSERT); Bundle bundle = new Bundle(); bundle.putString(Utils.BUNDLE_OPERATOR, operatorName); bundle.putString(Utils.BUNDLE_SIM_NUMBER, simSerial); i.putExtras(bundle);//from w ww.j a v a 2 s . com startActivity(i); break; } }
From source file:org.awesomeapp.messenger.ui.AccountViewFragment.java
private void initFragment() { Intent i = getIntent();//from w w w . jav a 2s .c o m mApp = (ImApp) getActivity().getApplication(); String action = i.getAction(); if (i.hasExtra("isSignedIn")) isSignedIn = i.getBooleanExtra("isSignedIn", false); final ProviderDef provider; mSignInHelper = new SignInHelper(getActivity(), new SimpleAlertHandler(getActivity())); SignInHelper.SignInListener signInListener = new SignInHelper.SignInListener() { @Override public void connectedToService() { } @Override public void stateChanged(int state, long accountId) { if (state == ImConnection.LOGGED_IN) { // mSignInHelper.goToAccount(accountId); // finish(); isSignedIn = true; } else { isSignedIn = false; } } }; mSignInHelper.setSignInListener(signInListener); ContentResolver cr = getActivity().getContentResolver(); Uri uri = i.getData(); // check if there is account information and direct accordingly if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) { if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) { action = Intent.ACTION_INSERT; } else { action = Intent.ACTION_EDIT; } } if (Intent.ACTION_INSERT.equals(action) && uri.getScheme().equals("ima")) { ImPluginHelper helper = ImPluginHelper.getInstance(getActivity()); String authority = uri.getAuthority(); String[] userpass_host = authority.split("@"); String[] user_pass = userpass_host[0].split(":"); mUserName = user_pass[0].toLowerCase(Locale.getDefault()); String pass = user_pass[1]; mDomain = userpass_host[1].toLowerCase(Locale.getDefault()); mPort = 0; final boolean regWithTor = i.getBooleanExtra("useTor", false); Cursor cursor = openAccountByUsernameAndDomain(cr); boolean exists = cursor.moveToFirst(); long accountId; if (exists) { accountId = cursor.getLong(0); mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId); pass = cursor.getString(ACCOUNT_PASSWORD_COLUMN); setAccountKeepSignedIn(true); mSignInHelper.activateAccount(mProviderId, accountId); mSignInHelper.signIn(pass, mProviderId, accountId, true); // setResult(RESULT_OK); cursor.close(); // finish(); return; } else { mProviderId = helper.createAdditionalProvider(helper.getProviderNames().get(0)); //xmpp FIXME accountId = ImApp.insertOrUpdateAccount(cr, mProviderId, -1, mUserName, mUserName, pass); mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId); mSignInHelper.activateAccount(mProviderId, accountId); createNewAccount(mUserName, pass, accountId, regWithTor); cursor.close(); return; } } else if (Intent.ACTION_INSERT.equals(action)) { mOriginalUserAccount = ""; // TODO once we implement multiple IM protocols mProviderId = ContentUris.parseId(uri); provider = mApp.getProvider(mProviderId); } else if (Intent.ACTION_EDIT.equals(action)) { if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) { LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity>Bad data"); return; } isEdit = true; Cursor cursor = cr.query(uri, ACCOUNT_PROJECTION, null, null, null); if (cursor == null) { return; } if (!cursor.moveToFirst()) { cursor.close(); return; } mAccountId = cursor.getLong(cursor.getColumnIndexOrThrow(BaseColumns._ID)); mProviderId = cursor.getLong(ACCOUNT_PROVIDER_COLUMN); provider = mApp.getProvider(mProviderId); Cursor pCursor = cr.query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(mProviderId) }, null); Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, cr, mProviderId, false /* don't keep updated */, null /* no handler */); try { mOriginalUserAccount = cursor.getString(ACCOUNT_USERNAME_COLUMN) + "@" + settings.getDomain(); mEditUserAccount.setText(mOriginalUserAccount); mEditPass.setText(cursor.getString(ACCOUNT_PASSWORD_COLUMN)); //mRememberPass.setChecked(!cursor.isNull(ACCOUNT_PASSWORD_COLUMN)); //mUseTor.setChecked(settings.getUseTor()); mBtnQrDisplay.setVisibility(View.VISIBLE); } finally { settings.close(); cursor.close(); } } else { LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity> unknown intent action " + action); return; } setupUIPost(); }