Example usage for android.content Intent getLongExtra

List of usage examples for android.content Intent getLongExtra

Introduction

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

Prototype

public long getLongExtra(String name, long defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.todoroo.astrid.repeats.RepeatControlSet.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PICK_DATE) {
        if (resultCode == Activity.RESULT_OK) {
            setRepeatUntilValue(data.getLongExtra(DatePickerActivity.EXTRA_TIMESTAMP, 0L));
        } else {/*ww  w  .  j a va2 s .c om*/
            setRepeatUntilValue(repeatUntilValue);
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SessionsFragment.java

public void reloadFromArguments(Bundle arguments, boolean reset) {
    mCheckedPosition = -1;//w ww.j a  v  a  2  s  .  c  o  m

    // Load new arguments
    final Intent intent = ActivityHelper.fragmentArgumentsToIntent(arguments);
    mSessionsUri = intent.getData();
    if (mSessionsUri == null) {
        return;
    }

    mNewSessionTimestamp = intent.getLongExtra(NewSessionsActivity.EXTRA_NEW_SESSION_TIMESTAMP, -1);

    final int sessionsQueryId;
    if (!CfpContract.Sessions.isSearchUri(mSessionsUri)) {
        mAdapter = new SessionsAdapter(getActivity(), null);
        sessionsQueryId = SessionsQuery._TOKEN;
    } else {
        mAdapter = new SearchAdapter(getActivity(), null);
        sessionsQueryId = SearchQuery._TOKEN;
    }

    setListAdapter(mAdapter);

    if (!reset) {
        getLoaderManager().initLoader(sessionsQueryId, null, mSessionsLoaderCallback);
    } else {
        getLoaderManager().restartLoader(sessionsQueryId, null, mSessionsLoaderCallback);
    }

    mTrackName = intent.getStringExtra(Intent.EXTRA_TITLE);
    mTrackColor = intent.getIntExtra(EXTRA_TRACK_COLOR, -1);
    final Uri trackUri = intent.getParcelableExtra(SessionsFragment.EXTRA_TRACK);
    if (!TextUtils.isEmpty(mTrackName)) {
        AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + mTrackName);
        updateTrackData();
    }
    if (TextUtils.isEmpty(mTrackName) && mTrackColor == -1 && trackUri != null) {
        Bundle args = new Bundle();
        args.putParcelable("uri", trackUri);
        getLoaderManager().initLoader(TracksQuery._TOKEN, args, mTrackLoaderCallback);
    }
}

From source file:ca.zadrox.dota2esportticker.service.ReminderAlarmService.java

@Override
protected void onHandleIntent(Intent intent) {
    final String action = intent.getAction();

    if (ACTION_NOTIFY_DEBUG.equals(action)) {
        notifyDebug();// w  w  w .  j a  v a  2  s .co  m
        return;
    }

    if (ACTION_SCHEDULE_ALL_STARRED_MATCHES.equals(action)) {
        scheduleAllStarredMatches();
        return;
    }

    final long matchId = intent.getLongExtra(ReminderAlarmService.EXTRA_MATCH_ID, UNDEFINED_VALUE);

    if (matchId == UNDEFINED_VALUE) {
        return;
    }

    if (ACTION_NOTIFY_MATCH.equals(action)) {
        notifyMatch(matchId);
    }

    final long matchStartTime = intent.getLongExtra(ReminderAlarmService.EXTRA_MATCH_START, UNDEFINED_VALUE);

    if (matchStartTime == UNDEFINED_VALUE) {
        return;
    }

    if (ACTION_SCHEDULE_STARRED_MATCH.equals(action)) {
        scheduleAlarm(matchId, matchStartTime);
    }

    if (ACTION_UNSCHEDULE_STARRED_MATCH.equals(action)) {
        cancelAlarm(matchId, matchStartTime);
    }
}

From source file:org.dharmaseed.android.PlayTalkActivity.java

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

    // Turn on action bar up/home button
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*from  w  ww.j  av  a  2s  .c o  m*/

    // Get the ID of the talk to display
    Intent i = getIntent();
    talkID = (int) i.getLongExtra(NavigationActivity.TALK_DETAIL_EXTRA, 0);

    dbManager = DBManager.getInstance(this);

    // only hit the DB again if we know the talk is different than the one
    // we have saved.
    // for example, if the user selects a talk, exits, and re-opens it, no need
    // to hit the DB again, since we already have that talk saved
    if (talk == null || talk.getId() != talkID) {
        Cursor cursor = getCursor();
        if (cursor.moveToFirst()) {
            // convert DB result to an object
            talk = new Talk(cursor);
            talk.setId(talkID);
        } else {
            Log.e(LOG_TAG, "Could not look up talk, id=" + talkID);
            cursor.close();
            return;
        }
        cursor.close();
    } // else we already have the talk, just re-draw the page

    // Set the talk title
    TextView titleView = (TextView) findViewById(R.id.play_talk_talk_title);
    titleView.setText(talk.getTitle());

    // Set the teacher name
    TextView teacherView = (TextView) findViewById(R.id.play_talk_teacher);
    teacherView.setText(talk.getTeacherName());

    // Set the center name
    TextView centerView = (TextView) findViewById(R.id.play_talk_center);
    centerView.setText(talk.getCenterName());

    // Set the talk description
    TextView descriptionView = (TextView) findViewById(R.id.play_talk_talk_description);
    descriptionView.setText(talk.getDescription());

    // Set teacher photo
    String photoFilename = talk.getPhotoFileName();
    ImageView photoView = (ImageView) findViewById(R.id.play_talk_teacher_photo);
    Log.i(LOG_TAG, "photoFilename: " + photoFilename);
    try {
        FileInputStream photo = openFileInput(photoFilename);
        photoView.setImageBitmap(BitmapFactory.decodeStream(photo));
    } catch (FileNotFoundException e) {
        Drawable icon = ContextCompat.getDrawable(this, R.drawable.dharmaseed_icon);
        photoView.setImageDrawable(icon);
    }

    // set the image of the download button based on whether the talk is
    // downloaded or not
    toggleDownloadImage();

    // Set date
    TextView dateView = (TextView) findViewById(R.id.play_talk_date);
    String recDate = talk.getDate();
    SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        dateView.setText(DateFormat.getDateInstance().format(parser.parse(recDate)));
    } catch (ParseException e) {
        dateView.setText("");
        Log.w(LOG_TAG, "Could not parse talk date for talk ID " + talkID);
    }

    // Get/create a persistent fragment to manage the MediaPlayer instance
    FragmentManager fm = getSupportFragmentManager();
    talkPlayerFragment = (TalkPlayerFragment) fm.findFragmentByTag("talkPlayerFragment");
    if (talkPlayerFragment == null) {
        // add the fragment
        talkPlayerFragment = new TalkPlayerFragment();
        fm.beginTransaction().add(talkPlayerFragment, "talkPlayerFragment").commit();
    } else if (talkPlayerFragment.getMediaPlayer().isPlaying()) {
        setPPButton("ic_media_pause");
    }

    // Set the talk duration
    final TextView durationView = (TextView) findViewById(R.id.play_talk_talk_duration);
    double duration = talk.getDurationInMinutes();
    String durationStr = DateUtils.formatElapsedTime((long) (duration * 60));
    durationView.setText(durationStr);

    // Start a handler to periodically update the seek bar and talk time
    final SeekBar seekBar = (SeekBar) findViewById(R.id.play_talk_seek_bar);
    seekBar.setMax((int) (duration * 60 * 1000));
    userDraggingSeekBar = false;
    userSeekBarPosition = 0;
    seekBar.setOnSeekBarChangeListener(this);
    final Handler handler = new Handler();
    final MediaPlayer mediaPlayer = talkPlayerFragment.getMediaPlayer();
    handler.post(new Runnable() {
        @Override
        public void run() {
            handler.postDelayed(this, 1000);
            if (talkPlayerFragment.getMediaPrepared() && !userDraggingSeekBar) {
                try {
                    int pos = mediaPlayer.getCurrentPosition();
                    int mpDuration = mediaPlayer.getDuration();
                    seekBar.setMax(mpDuration);
                    seekBar.setProgress(pos);
                    String posStr = DateUtils.formatElapsedTime(pos / 1000);
                    String mpDurStr = DateUtils.formatElapsedTime(mpDuration / 1000);
                    durationView.setText(posStr + "/" + mpDurStr);
                } catch (IllegalStateException e) {
                }
            }
        }
    });
}

From source file:ivl.android.moneybalance.ExpenseEditorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);

    setContentView(R.layout.expense_editor);
    titleView = (AutoCompleteTextView) findViewById(R.id.expense_title);
    amountView = (EditText) findViewById(R.id.expense_amount);
    currencySpinner = (Spinner) findViewById(R.id.expense_currency);
    payerView = (TextView) findViewById(R.id.expense_payer);
    dateView = (TextView) findViewById(R.id.expense_date);

    customSplitCheckBox = (CheckBox) findViewById(R.id.custom_split);
    customSplitTable = (TableLayout) findViewById(R.id.expense_split_table);

    Intent intent = getIntent();

    long calculationId = intent.getLongExtra(PARAM_CALCULATION_ID, -1);
    long expenseId = intent.getLongExtra(PARAM_EXPENSE_ID, -1);

    calculation = calculationDataSource.get(calculationId);
    persons = calculation.getPersons();//from   w ww .  java 2s .co  m

    expenseDataSource = new ExpenseDataSource(dbHelper, calculation);

    mode = (expenseId >= 0 ? Mode.EDIT_EXPENSE : Mode.NEW_EXPENSE);
    if (mode == Mode.EDIT_EXPENSE) {
        setTitle(R.string.edit_expense);
        expense = expenseDataSource.get(expenseId);
        titleView.setText(expense.getTitle());
    } else {
        setTitle(R.string.new_expense);
        expense = new Expense(calculation);
        long personId = intent.getLongExtra(PARAM_PERSON_ID, -1);
        expense.setPerson(calculation.getPersonById(personId));
        long millis = intent.getLongExtra(PARAM_DATE, -1);
        if (millis > 0) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(millis);
            expense.setDate(cal);
        }
    }

    List<java.util.Currency> currencies = new ArrayList<>();
    for (Currency currency : calculation.getCurrencies())
        currencies.add(java.util.Currency.getInstance(currency.getCurrencyCode()));
    CurrencySpinnerAdapter adapter = new CurrencySpinnerAdapter(this, currencies);
    adapter.setSymbolOnly(true);

    Currency currency = expense.getCurrency();
    currencyHelper = currency.getCurrencyHelper();
    currencySpinner.setAdapter(adapter);
    currencySpinner.setSelection(adapter.findItem(currency.getCurrencyCode()));
    currencySpinner.setEnabled(currencies.size() > 1);

    currencySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updateCurrency();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    if (mode == Mode.EDIT_EXPENSE) {
        String formatted = currencyHelper.format(expense.getAmount(), false);
        amountView.setText(formatted);
    }

    Set<String> expenseTitles = new HashSet<>();
    for (Expense expense : calculation.getExpenses())
        expenseTitles.add(expense.getTitle());
    ArrayAdapter<String> expenseTitlesAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            expenseTitles.toArray(new String[expenseTitles.size()]));
    titleView.setAdapter(expenseTitlesAdapter);
    titleView.setThreshold(1);

    createCustomSplitRows();
    updateCustomSplit();
    updatePayer();
    updateDate();

    customSplitCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            customSplitTable.setVisibility(isChecked ? View.VISIBLE : View.GONE);
        }
    });

    amountView.addTextChangedListener(updateCustomSplitTextWatcher);

    payerView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pickPayer();
        }
    });

    dateView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pickDate();
        }
    });
}

From source file:org.mariotaku.twidere.activity.support.UserProfileEditorActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
    if (!isMyAccount(this, accountId)) {
        finish();//from  w  ww . ja v a  2s.  co m
        return;
    }
    mAsyncTaskManager = TwidereApplication.getInstance(this).getAsyncTaskManager();
    mLazyImageLoader = TwidereApplication.getInstance(this).getImageLoaderWrapper();
    mAccountId = accountId;
    setContentView(R.layout.edit_user_profile);
    // setOverrideExitAniamtion(false);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    mProfileImageBannerLayout.setOnSizeChangedListener(this);
    mEditName.addTextChangedListener(this);
    mEditDescription.addTextChangedListener(this);
    mEditLocation.addTextChangedListener(this);
    mEditUrl.addTextChangedListener(this);
    mProfileImageView.setOnClickListener(this);
    mProfileBannerView.setOnClickListener(this);
    if (savedInstanceState != null && savedInstanceState.getParcelable(EXTRA_USER) != null) {
        final ParcelableUser user = savedInstanceState.getParcelable(EXTRA_USER);
        displayUser(user);
        mEditName.setText(savedInstanceState.getString(EXTRA_NAME, user.name));
        mEditLocation.setText(savedInstanceState.getString(EXTRA_LOCATION, user.location));
        mEditDescription.setText(savedInstanceState.getString(EXTRA_DESCRIPTION, user.description_expanded));
        mEditUrl.setText(savedInstanceState.getString(EXTRA_URL, user.url_expanded));
    } else {
        getUserInfo();
    }
}

From source file:com.newtifry.android.SourceEditor.java

/**
 * Fetch the account that this source list is for.
 * /*from  w  ww .j a  v  a2 s . c  om*/
 * @return
 */
public NewtifrySource getSource() {
    if (this.source == null) {
        // Get the source from the intent.
        // We store it in a private variable to save us having to query the
        // DB each time.
        Intent sourceIntent = getIntent();
        this.source = NewtifrySource.FACTORY.get(this, sourceIntent.getLongExtra("sourceId", 0));
    }

    return this.source;
}

From source file:com.ola.insta.BookingAcivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutId());//from w w w . j a v a2s  . c o  m
    mTextToSpeech = new TextToSpeech(this, this);

    mUtility = new Utilities();
    mProgressDialog = mUtility.GetProcessDialog(this);
    context = BookingAcivity.this;

    Intent intent = getIntent();
    mCabId = intent.getStringExtra(Constants.CAB_ID);
    mCabLat = intent.getDoubleExtra(Constants.CAB_LAT, 0.0);
    mCabLng = intent.getDoubleExtra(Constants.CAB_LANG, 0.0);
    mCabEta = intent.getLongExtra(Constants.CAB_ETA, 0);
    init();
}

From source file:br.com.bioscada.apps.biotracks.TrackDetailActivity.java

/**
 * Handles the data in the intent.//from  w  w  w .  j a v  a  2  s. co  m
 */
private void handleIntent(Intent intent) {
    trackId = intent.getLongExtra(EXTRA_TRACK_ID, -1L);
    markerId = intent.getLongExtra(EXTRA_MARKER_ID, -1L);
    if (markerId != -1L) {
        // Use the trackId from the marker
        Waypoint waypoint = myTracksProviderUtils.getWaypoint(markerId);
        if (waypoint == null) {
            finish();
            return;
        }
        trackId = waypoint.getTrackId();
    }
    if (trackId == -1L) {
        finish();
        return;
    }
    Track track = myTracksProviderUtils.getTrack(trackId);
    if (track == null) {
        // Use the last track if markerId is not set
        if (markerId == -1L) {
            track = myTracksProviderUtils.getLastTrack();
            if (track != null) {
                trackId = track.getId();
                return;
            }
        }
        finish();
        return;
    }
}

From source file:org.sufficientlysecure.keychain.service.PassphraseCacheService.java

/**
 * Executed when service is started by intent
 *//*from  ww  w . j a va  2 s. c  o  m*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "onStartCommand()");

    // register broadcastreceiver
    registerReceiver();

    if (intent != null && intent.getAction() != null) {
        if (ACTION_PASSPHRASE_CACHE_ADD.equals(intent.getAction())) {
            long ttl = intent.getLongExtra(EXTRA_TTL, DEFAULT_TTL);
            long keyId = intent.getLongExtra(EXTRA_KEY_ID, -1);
            String passphrase = intent.getStringExtra(EXTRA_PASSPHRASE);

            Log.d(TAG, "Received ACTION_PASSPHRASE_CACHE_ADD intent in onStartCommand() with keyId: " + keyId
                    + ", ttl: " + ttl);

            // add keyId and passphrase to memory
            mPassphraseCache.put(keyId, passphrase);

            if (ttl > 0) {
                // register new alarm with keyId for this passphrase
                long triggerTime = new Date().getTime() + (ttl * 1000);
                AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
                am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, keyId));
            }
        } else if (ACTION_PASSPHRASE_CACHE_GET.equals(intent.getAction())) {
            long keyId = intent.getLongExtra(EXTRA_KEY_ID, -1);
            Messenger messenger = intent.getParcelableExtra(EXTRA_MESSENGER);

            String passphrase = getCachedPassphraseImpl(keyId);

            Message msg = Message.obtain();
            Bundle bundle = new Bundle();
            bundle.putString(EXTRA_PASSPHRASE, passphrase);
            msg.obj = bundle;
            try {
                messenger.send(msg);
            } catch (RemoteException e) {
                Log.e(Constants.TAG, "Sending message failed", e);
            }
        } else {
            Log.e(Constants.TAG, "Intent or Intent Action not supported!");
        }
    }

    return START_STICKY;
}