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.ultramegasoft.flavordex2.ViewEntryActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//from ww  w .  j a v  a2s .  c o  m

    if (savedInstanceState == null) {
        final Intent intent = getIntent();
        final Bundle arguments = new Bundle();
        arguments.putLong(ViewEntryFragment.ARG_ENTRY_ID,
                intent.getLongExtra(ViewEntryFragment.ARG_ENTRY_ID, 0));
        arguments.putString(ViewEntryFragment.ARG_ENTRY_CAT,
                intent.getStringExtra(ViewEntryFragment.ARG_ENTRY_CAT));
        arguments.putLong(ViewEntryFragment.ARG_ENTRY_CAT_ID,
                intent.getLongExtra(ViewEntryFragment.ARG_ENTRY_CAT_ID, 0));

        final ViewEntryFragment fragment = new ViewEntryFragment();
        fragment.setArguments(arguments);

        getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
    }
}

From source file:ru.yandex.subtitles.service.speechkit.speaker.SpeakerBroadcastReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    final String action = (intent != null ? intent.getAction() : null);
    if (ACTION_START_PLAYING.equals(action)) {
        final long messageId = intent.getLongExtra(EXTRA_MESSAGE_ID, -1);
        mSpeakerEventListener.onStartPlaying(messageId);

    } else if (ACTION_STOP_PLAYING.equals(action)) {
        final long messageId = intent.getLongExtra(EXTRA_MESSAGE_ID, -1);
        mSpeakerEventListener.onStopPlaying(messageId);

    }//from  ww w  . j  a  v  a 2 s  .co m
}

From source file:uk.org.rivernile.edinburghbustracker.android.alerts.TimeAlertService.java

/**
 * Reschedule the retrieval of bus times from the server because there was
 * an error loading them or the service/time criteria has not been met.
 * /*from   w  ww  .j a v  a 2 s.c  o m*/
 * If the rescheduling goes on for an hour, then cancel the checking and
 * remove the alert otherwise the user's battery will be drained and data
 * used.
 * 
 * @param intent The intent that started this service. This is to be reused
 * to start the next service at the appropriate time.
 */
private void reschedule(final Intent intent) {
    final long timeSet = intent.getLongExtra(ARG_TIME_SET, 0);

    // Checks to see if the alert has been active for the last hour or more.
    // If so, it gets cancelled.
    if ((SystemClock.elapsedRealtime() - timeSet) >= 3600000) {
        alertMan.removeTimeAlert();
        return;
    }

    final PendingIntent pi = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    // Reschedule ourself to run again in 60 seconds.
    alarmMan.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60000, pi);
}

From source file:eu.geopaparazzi.library.forms.views.GPictureView.java

@Override
public void setOnActivityResult(Intent data) {
    long imageId = data.getLongExtra(LibraryConstants.DATABASE_ID, -1);
    if (imageId == -1) {
        return;/*from   w  w w. ja v a2 s.  c o m*/
    }
    _value = _value + IMAGE_ID_SEPARATOR + imageId;
    try {
        refresh(getContext());
    } catch (Exception e) {
        GPLog.error(this, null, e);
    }
}

From source file:org.isoron.uhabits.HabitBroadcastReceiver.java

private void checkHabit(Context context, Intent intent) {
    Uri data = intent.getData();//  ww w  . j a v a2 s.  c  om
    Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());

    long habitId = ContentUris.parseId(data);
    Habit habit = Habit.get(habitId);
    if (habit != null)
        habit.repetitions.toggle(timestamp);
    dismissNotification(context, habitId);

    sendRefreshBroadcast(context);
}

From source file:org.schabi.etherwake.HostSettingsActivityFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    hostEdit = (EditText) getView().findViewById(R.id.settingsHostEdit);
    macEdit = (EditText) getView().findViewById(R.id.settingsMacEdit);
    pwdEdit = (EditText) getView().findViewById(R.id.settingsPwdEdit);
    broadcastCheckBox = (CheckBox) getView().findViewById(R.id.broadcastCheckBox);

    Intent intent = getActivity().getIntent();
    if (intent.getIntExtra(MainActivity.REQUEST_CODE, -1) == MainActivity.EDIT_HOST_REQUEST) {
        currentId = intent.getLongExtra(ID, -1);
        hostEdit.setText(intent.getStringExtra(HOST_VALUE));
        macEdit.setText(intent.getStringExtra(MAC_VALUE));
        pwdEdit.setText(intent.getStringExtra(PWD_VALUE));
        broadcastCheckBox.setChecked(intent.getBooleanExtra(BROADCAST_VALUE, false));
    }/*from  w  ww .j  a  va 2 s .  c  om*/

    Button savedButton = (Button) getView().findViewById(R.id.saveButton);
    savedButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!hostEdit.getText().toString().isEmpty() && !macEdit.getText().toString().isEmpty()) {
                Intent input = getActivity().getIntent();
                Intent output = new Intent();
                output.putExtra(MainActivity.REQUEST_CODE, input.getIntExtra(MainActivity.REQUEST_CODE, -1));
                output.putExtra(ID, input.getLongExtra(ID, -1)); //only needed for EDIT_HOST_REQUEST
                                                                 //will be discard for NEW_HOST_REQUEST
                output.putExtra(HOST_VALUE, hostEdit.getText().toString());
                output.putExtra(MAC_VALUE, macEdit.getText().toString());
                output.putExtra(PWD_VALUE, pwdEdit.getText().toString());
                output.putExtra(BROADCAST_VALUE, broadcastCheckBox.isChecked());
                getActivity().setResult(Activity.RESULT_OK, output);
                getActivity().finish();
            } else {
                Toast.makeText(getActivity().getApplicationContext(), R.string.onSaveWrongToast,
                        Toast.LENGTH_LONG).show();
            }
        }
    });
}

From source file:pl.kodujdlapolski.na4lapy.ui.browse.list.ListBrowseActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == DetailsActivity.REQUEST_CODE_ANIMAL && resultCode == Activity.RESULT_OK) {
        Long changedAnimalId = data.getLongExtra(DetailsActivity.EXTRA_ANIMAL_ID, -1);
        if (changedAnimalId != -1)
            browsePresenter.onChangedAnimalAvailable(changedAnimalId);
    }/*from   w  w  w  .j  av  a 2s  .  c  o  m*/
}

From source file:ru.yandex.subtitles.service.speechkit.recognition.RecognitionBroadcastReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    final String action = (intent != null ? intent.getAction() : null);
    final long threadId = (intent != null ? intent.getLongExtra(EXTRA_THREAD_ID, -1) : -1);
    if (mThreadId == threadId) {
        if (ACTION_RECOGNITION_STARTED.equals(action)) {
            final boolean resumedAfterPlaying = intent.getBooleanExtra(EXTRA_RESUMED_AFTER_PLAYING, false);
            mCallbacks.onRecognitionStarted(resumedAfterPlaying);

        } else if (ACTION_POWER_UPDATE.equals(action)) {
            mCallbacks.onPowerUpdate(intent.getFloatExtra(EXTRA_POWER, 0.f));

        } else if (ACTION_ERROR.equals(action)) {
            mCallbacks.onError(Error.fromCode(intent.getIntExtra(EXTRA_ERROR, Error.ERROR_UNKNOWN)));

        } else if (ACTION_RECOGNITION_DONE.equals(action)) {
            final boolean willStartPlaying = intent.getBooleanExtra(EXTRA_WILL_START_PLAYING, false);
            mCallbacks.onRecognitionDone(willStartPlaying);

        }// w  w w. j a va 2  s .com
    }
}

From source file:ru.orangesoftware.financisto.service.FinancistoService.java

private void notifyAboutNewTransaction(Intent intent) {
    long newTransactionId = intent.getLongExtra(SMS_NEW_TRANSACTION_ID, -1);

    TransactionInfo transaction = db.em().getTransactionInfo(newTransactionId);
    if (transaction != null) {
        notifyUser(transaction);//  www . j  av  a 2s.c o  m
        AccountWidget.updateWidgets(this);
    }
}

From source file:ru.yandex.subtitles.service.messaging.CreateConversationBroadcastReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    final String action = (intent != null ? intent.getAction() : null);
    if (ACTION_CONVERSATION_CREATED.equals(action)) {
        final long threadId = intent.getLongExtra(EXTRA_CONVERSATION, -1);
        final Long messageId = (Long) intent.getSerializableExtra(EXTRA_MESSAGE);
        final Long memberId = (Long) intent.getSerializableExtra(EXTRA_MEMBER);
        mOnCreateConversationListener.onConversationCreated(threadId, messageId, memberId);

    } else if (ACTION_CONVERSATION_ERROR.equals(action)) {
        final int kind = intent.getIntExtra(EXTRA_KIND, ConversationError.KIND_UNKNOWN);
        mOnCreateConversationListener.onConversationCreateError(kind);

    }//  w  w  w .  ja va2  s.co m
}