Example usage for android.content Intent ACTION_INSERT_OR_EDIT

List of usage examples for android.content Intent ACTION_INSERT_OR_EDIT

Introduction

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

Prototype

String ACTION_INSERT_OR_EDIT

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

Click Source Link

Document

Activity Action: Pick an existing item, or insert a new item, and then edit it.

Usage

From source file:org.hfoss.posit.android.api.fragment.FindFragment.java

/**
 * This may be invoked by a FindActivity subclass, which may or may not have
 * latitude and longitude fields./*from  w ww .  j a va2s . com*/
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {

    super.onActivityCreated(savedInstanceState);

    // Sets listeners for various UI elements
    initializeListeners();

    mAddFindMenuPlugins = FindPluginManager.getFunctionPlugins(FindPluginManager.ADD_FIND_MENU_EXTENSION);

    setHasOptionsMenu(true);

    // Initialize all UI elements for later uses
    mNameET = (EditText) getView().findViewById(R.id.nameEditText);
    mDescriptionET = (EditText) getView().findViewById(R.id.descriptionEditText);
    mGuidTV = (TextView) getView().findViewById(R.id.guidValueTextView);
    mGuidRealTV = (TextView) getView().findViewById(R.id.guidRealValueTextView);
    mTimeTV = (TextView) getView().findViewById(R.id.timeValueTextView);
    mLatTV = (TextView) getView().findViewById(R.id.latitudeTextView);
    mLatitudeTV = (TextView) getView().findViewById(R.id.latitudeValueTextView);
    mLongTV = (TextView) getView().findViewById(R.id.longitudeTextView);
    mLongitudeTV = (TextView) getView().findViewById(R.id.longitudeValueTextView);
    mAdhocTV = (TextView) getView().findViewById(R.id.isAdhocTextView);

    // Check if settings allow Geotagging
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mGeoTagEnabled = prefs.getBoolean("geotagKey", true);

    // If enabled, get location manager and provider
    if (mGeoTagEnabled) {
        mLocationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    }

    // Set the content of UI elements, either auto-generated or retrieved
    // from a Find
    Bundle extras = getArguments();

    if (extras != null && !(extras.size() == 1 && extras.containsKey("ACTION"))) {
        // Existing Find
        if (getAction().equals(Intent.ACTION_EDIT)) {
            int id = extras.getInt(Find.ORM_ID);
            Log.i(TAG, "ORM_id = " + id);
            //            Find find = getHelper().getFindById(id);
            mFind = getHelper().getFindById(id);
            Log.i(TAG, "Updating: " + mFind);
            displayContentInView(mFind);
        } else

        // Bundled Find (from SMS)
        if (getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) {
            // Pull a Bundle corresponding to a Find from the Intent and put
            // that in the view
            Bundle findBundle = extras.getBundle("findbundle");
            //Find find;
            try {
                FindPlugin plugin = FindPluginManager.mFindPlugin;
                if (plugin == null) {
                    Log.e(TAG, "Could not retrieve Find Plugin.");
                    Toast.makeText(getActivity(), "A fatal error occurred while trying to start FindActivity",
                            Toast.LENGTH_LONG).show();
                    getActivity().finish();
                    return;
                }
                mFind = plugin.getmFindClass().newInstance();
            } catch (IllegalAccessException e) {
                Toast.makeText(getActivity(), "A fatal error occurred while trying to start FindActivity",
                        Toast.LENGTH_LONG).show();
                getActivity().finish();
                return;
            } catch (java.lang.InstantiationException e) {
                Toast.makeText(getActivity(), "A fatal error occurred while trying to start FindActivity",
                        Toast.LENGTH_LONG).show();
                getActivity().finish();
                return;
            }
            mFind.updateObject(findBundle);
            displayContentInView(mFind);
        } else
        // CSV Find   
        if (getAction().equals(CsvListFindsFragment.ACTION_CSV_FINDS)) {

        }
        // New Find
    } else {
        Log.i("TAG", "new find");
        // Set real GUID
        if (mGuidRealTV != null)
            mGuidRealTV.setText(UUID.randomUUID().toString());
        // Set displayed GUID
        if (mGuidTV != null)
            mGuidTV.setText(mGuidRealTV.getText().toString().substring(0, 8) + "...");
        // Set Time
        if (mTimeTV != null) {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            Date date = new Date();
            mTimeTV.setText(dateFormat.format(date));
        }

        if (mGeoTagEnabled) {
            // Set Longitude and Latitude
            mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 0, this);
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this);

            Location netLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            Location gpsLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

            if (gpsLocation != null) {
                mCurrentLocation = gpsLocation;
            } else {
                mCurrentLocation = netLocation;
            }

            if (mCurrentLocation == null) {
                Log.i(TAG, "Location issue, mCurrentLocation = " + mCurrentLocation);
                if (mLongitudeTV != null)
                    mLongitudeTV.setText("0.0");
                if (mLatitudeTV != null)
                    mLatitudeTV.setText("0.0");
                // Toast.makeText(this, "Unable to retrieve GPS info." +
                // " Please make sure your Data or Wi-Fi is enabled.",
                // Toast.LENGTH_SHORT).show();
                // Log.i(TAG,
                // "Cannot request location updates; Data or Wifi might not be enabled.");
            } else {
                if (mLongitudeTV != null)
                    mLongitudeTV.setText(String.valueOf(mCurrentLocation.getLongitude()));
                if (mLatitudeTV != null)
                    mLatitudeTV.setText(String.valueOf(mCurrentLocation.getLatitude()));
            }
        } else {
            if (mLongitudeTV != null && mLongTV != null) {
                mLongitudeTV.setVisibility(TextView.INVISIBLE);
                mLongTV.setVisibility(TextView.INVISIBLE);
            }
            if (mLatitudeTV != null && mLatTV != null) {
                mLatitudeTV.setVisibility(TextView.INVISIBLE);
                mLatTV.setVisibility(TextView.INVISIBLE);
            }
        }
    }
}

From source file:org.awesomeapp.messenger.ui.AccountViewFragment.java

private void initFragment() {

    Intent i = getIntent();//from  ww w  .  ja va  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();

}

From source file:org.gnucash.android.ui.widget.WidgetConfigurationActivity.java

/**
 * Updates the widget with id <code>appWidgetId</code> with information from the 
 * account with record ID <code>accountId</code>
  * If the account has been deleted, then a notice is posted in the widget
  * @param appWidgetId ID of the widget to be updated
  * @param accountId Database ID of the account tied to the widget
 *//*from  w w  w.  j  ava  2  s . c  o  m*/
public static void updateWidget(Context context, int appWidgetId, long accountId) {
    Log.i("WidgetConfiguration", "Updating widget: " + appWidgetId);
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

    AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(context);
    Account account = accountsDbAdapter.getAccount(accountId);

    if (account == null) {
        Log.i("WidgetConfiguration", "Account not found, resetting widget " + appWidgetId);
        //if account has been deleted, let the user know
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_4x1);
        views.setTextViewText(R.id.account_name, context.getString(R.string.toast_account_deleted));
        views.setTextViewText(R.id.transactions_summary, "");
        //set it to simply open the app
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                new Intent(context, AccountsActivity.class), 0);
        views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent);
        views.setOnClickPendingIntent(R.id.btn_new_transaction, pendingIntent);
        appWidgetManager.updateAppWidget(appWidgetId, views);
        Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
        editor.remove(UxArgument.SELECTED_ACCOUNT_ID + appWidgetId);
        editor.commit();
        return;
    }

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_4x1);
    views.setTextViewText(R.id.account_name, account.getName());
    Money accountBalance = accountsDbAdapter.getAccountBalance(accountId);

    views.setTextViewText(R.id.transactions_summary, accountBalance.formattedString(Locale.getDefault()));
    int color = account.getBalance().isNegative() ? R.color.debit_red : R.color.credit_green;
    views.setTextColor(R.id.transactions_summary, context.getResources().getColor(color));

    Intent accountViewIntent = new Intent(context, TransactionsActivity.class);
    accountViewIntent.setAction(Intent.ACTION_VIEW);
    accountViewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    accountViewIntent.putExtra(UxArgument.SELECTED_ACCOUNT_ID, accountId);
    PendingIntent accountPendingIntent = PendingIntent.getActivity(context, appWidgetId, accountViewIntent, 0);
    views.setOnClickPendingIntent(R.id.widget_layout, accountPendingIntent);

    Intent newTransactionIntent = new Intent(context, TransactionsActivity.class);
    newTransactionIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
    newTransactionIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    newTransactionIntent.putExtra(UxArgument.SELECTED_ACCOUNT_ID, accountId);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, newTransactionIntent, 0);
    views.setOnClickPendingIntent(R.id.btn_new_transaction, pendingIntent);

    appWidgetManager.updateAppWidget(appWidgetId, views);
}

From source file:org.gnucash.android.ui.transaction.ScheduledTransactionsListFragment.java

/**
 * Opens the transaction editor to enable editing of the transaction
 * @param accountId Account ID of the transaction
 * @param transactionId Transaction to be edited
 *///from w  ww.  j  av a2 s  .c o m
public void openTransactionForEdit(long accountId, long transactionId) {
    Intent createTransactionIntent = new Intent(getActivity(), TransactionsActivity.class);
    createTransactionIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
    createTransactionIntent.putExtra(UxArgument.SELECTED_ACCOUNT_ID, accountId);
    createTransactionIntent.putExtra(UxArgument.SELECTED_TRANSACTION_ID, transactionId);
    startActivity(createTransactionIntent);
}

From source file:org.gnucash.android.ui.account.AccountsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_accounts);

    init();/*from www.j av a 2s  .c om*/

    mPager = (ViewPager) findViewById(R.id.pager);
    TitlePageIndicator titlePageIndicator = (TitlePageIndicator) findViewById(R.id.titles);

    final Intent intent = getIntent();
    String action = intent.getAction();
    if (action != null && action.equals(Intent.ACTION_INSERT_OR_EDIT)) {
        //enter account creation/edit mode if that was specified
        mPager.setVisibility(View.GONE);
        titlePageIndicator.setVisibility(View.GONE);

        long accountId = intent.getLongExtra(UxArgument.SELECTED_ACCOUNT_ID, 0L);
        if (accountId > 0)
            showEditAccountFragment(accountId);
        else {
            long parentAccountId = intent.getLongExtra(UxArgument.PARENT_ACCOUNT_ID, 0L);
            showAddAccountFragment(parentAccountId);
        }
    } else if (action != null && action.equals(ACTION_VIEW_RECURRING)) {
        mPager.setVisibility(View.GONE);
        titlePageIndicator.setVisibility(View.GONE);
        showRecurringTransactionsFragment();
    } else {
        //show the simple accounts list
        PagerAdapter mPagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager());
        mPager.setAdapter(mPagerAdapter);
        titlePageIndicator.setViewPager(mPager);

        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
        int lastTabIndex = preferences.getInt(LAST_OPEN_TAB_INDEX, INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT);
        mPager.setCurrentItem(lastTabIndex);
    }

}

From source file:com.google.zxing.client.android.result.ResultHandler.java

final void addContact(String[] names, String[] nicknames, String pronunciation, String[] phoneNumbers,
        String[] phoneTypes, String[] emails, String[] emailTypes, String note, String instantMessenger,
        String address, String addressType, String org, String title, String[] urls, String birthday,
        String[] geo) {/*  w  w w  .ja  v  a  2 s .  co m*/

    // Only use the first name in the array, if present.
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, ContactsContract.Contacts.CONTENT_URI);
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    putExtra(intent, ContactsContract.Intents.Insert.NAME, names != null ? names[0] : null);

    putExtra(intent, ContactsContract.Intents.Insert.PHONETIC_NAME, pronunciation);

    int phoneCount = Math.min(phoneNumbers != null ? phoneNumbers.length : 0, Contents.PHONE_KEYS.length);
    for (int x = 0; x < phoneCount; x++) {
        putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]);
        if (phoneTypes != null && x < phoneTypes.length) {
            int type = toPhoneContractType(phoneTypes[x]);
            if (type >= 0) {
                intent.putExtra(Contents.PHONE_TYPE_KEYS[x], type);
            }
        }
    }

    int emailCount = Math.min(emails != null ? emails.length : 0, Contents.EMAIL_KEYS.length);
    for (int x = 0; x < emailCount; x++) {
        putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]);
        if (emailTypes != null && x < emailTypes.length) {
            int type = toEmailContractType(emailTypes[x]);
            if (type >= 0) {
                intent.putExtra(Contents.EMAIL_TYPE_KEYS[x], type);
            }
        }
    }

    // No field for URL, birthday; use notes
    StringBuilder aggregatedNotes = new StringBuilder();
    if (urls != null) {
        for (String url : urls) {
            if (url != null && url.length() > 0) {
                aggregatedNotes.append('\n').append(url);
            }
        }
    }
    for (String aNote : new String[] { birthday, note }) {
        if (aNote != null) {
            aggregatedNotes.append('\n').append(aNote);
        }
    }
    if (nicknames != null) {
        for (String nickname : nicknames) {
            if (nickname != null && nickname.length() > 0) {
                aggregatedNotes.append('\n').append(nickname);
            }
        }
    }
    if (geo != null) {
        aggregatedNotes.append('\n').append(geo[0]).append(',').append(geo[1]);
    }

    if (aggregatedNotes.length() > 0) {
        // Remove extra leading '\n'
        putExtra(intent, ContactsContract.Intents.Insert.NOTES, aggregatedNotes.substring(1));
    }

    putExtra(intent, ContactsContract.Intents.Insert.IM_HANDLE, instantMessenger);
    putExtra(intent, ContactsContract.Intents.Insert.POSTAL, address);
    if (addressType != null) {
        int type = toAddressContractType(addressType);
        if (type >= 0) {
            intent.putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, type);
        }
    }
    putExtra(intent, ContactsContract.Intents.Insert.COMPANY, org);
    putExtra(intent, ContactsContract.Intents.Insert.JOB_TITLE, title);
    launchIntent(intent);
}

From source file:net.potterpcs.recipebook.RecipeListFragment.java

public void onEditItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Uri uri = new Uri.Builder().scheme("content").authority("net.potterpcs.recipebook").build();
    uri = ContentUris.withAppendedId(uri, info.id);
    //      Log.i(TAG, "edit option selected, id=" + info.id);
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, uri);
    startActivity(intent);/*from  w w w. ja va2 s . co m*/
}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public void launchAddContactActivity(final Context context, final String destination) {
    final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    final String destinationType = MmsSmsUtils.isEmailAddress(destination) ? Intents.Insert.EMAIL
            : Intents.Insert.PHONE;/*ww  w.  j a v a  2  s. c om*/
    intent.setType(Contacts.CONTENT_ITEM_TYPE);
    intent.putExtra(destinationType, destination);
    startExternalActivity(context, intent);
}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private boolean initActivityState(Intent intent) {
    /**/*from   w  w  w . j  av  a 2 s  .  co  m*/
     * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id,
     * then jump to the NotesListActivity
     */
    mWorkingNote = null;
    if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
        long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
        mUserQuery = "";

        /**
         * Starting from the searched result
         */
        if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) {
            noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
            mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY);
        }

        if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
            Intent jump = new Intent(this, NotesListActivity.class);
            startActivity(jump);
            showToast(R.string.error_note_not_exist);
            finish();
            return false;
        } else {
            mWorkingNote = WorkingNote.load(this, noteId);
            if (mWorkingNote == null) {
                Log.e(TAG, "load note failed with note id" + noteId);
                finish();
                return false;
            }
        }
    } else if (TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
        // New note
        long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
        int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, Notes.TYPE_WIDGET_INVALIDE);
        int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, ResourceParser.getDefaultBgId(this));

        // Parse call-record note
        String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0);
        if (callDate != 0 && phoneNumber != null) {
            if (TextUtils.isEmpty(phoneNumber)) {
                Log.w(TAG, "The call record number is null");
            }
            long noteId = 0;
            if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(), phoneNumber,
                    callDate)) > 0) {
                mWorkingNote = WorkingNote.load(this, noteId);
                if (mWorkingNote == null) {
                    Log.e(TAG, "load call note failed with note id" + noteId);
                    finish();
                    return false;
                }
            } else {
                mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId);
                mWorkingNote.convertToCallNote(phoneNumber, callDate);
            }
        } else {
            mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId);
        }
    } else {
        Log.e(TAG, "Intent not specified action, should not support");
        finish();
        return false;
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
            | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mWorkingNote.setOnSettingStatusChangedListener(this);
    return true;
}

From source file:org.gnucash.android.ui.transaction.TransactionsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transactions);

    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    mTitlePageIndicator = (TitlePageIndicator) findViewById(R.id.titles);
    mSectionHeaderTransactions = (TextView) findViewById(R.id.section_header_transactions);

    if (sLastTitleColor == -1) //if this is first launch of app. Previous launches would have set the color already
        sLastTitleColor = getResources().getColor(R.color.title_green);

    mAccountId = getIntent().getLongExtra(UxArgument.SELECTED_ACCOUNT_ID, -1);

    mAccountsDbAdapter = new AccountsDbAdapter(this);

    setupActionBarNavigation();/*from   w  w  w.j av  a 2  s . c  o m*/

    if (getIntent().getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) {
        pager.setVisibility(View.GONE);
        mTitlePageIndicator.setVisibility(View.GONE);

        initializeCreateOrEditTransaction();
    } else { //load the transactions list
        mSectionHeaderTransactions.setVisibility(View.GONE);

        PagerAdapter pagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager());
        pager.setAdapter(pagerAdapter);
        mTitlePageIndicator.setViewPager(pager);

        pager.setCurrentItem(INDEX_TRANSACTIONS_FRAGMENT);
    }

    // done creating, activity now running
    mActivityRunning = true;
}