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.android.sandwichmaker.ui.NotifyService.java

@Override
protected void onHandleIntent(Intent intent) {
    mMessage = intent.getStringExtra(CommonConstants.EXTRA_MESSAGE);
    mMillis = intent.getLongExtra(CommonConstants.EXTRA_TIMER, CommonConstants.DEFAULT_TIMER_DURATION);
    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    //   nm.cancel(CommonConstants.NOTIFICATION_ID);
    String action = intent.getAction();
    if (action.equals(CommonConstants.ACTION_PING)) {
        issueNotification(intent, mMessage);
    }//from  w  ww  .j  av  a 2 s .  com

}

From source file:com.kylebeal.datedialogfragment.example.DateDetailActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.date_detail_activity);

    //get the launching intent
    Intent launchingIntent = getIntent();

    //get the id for the date passed in the intent
    long dateId = launchingIntent.getLongExtra("date_id", 0);

    //get the Date Detail Fragment
    DateDetailFragment ddf = (DateDetailFragment) getSupportFragmentManager()
            .findFragmentById(R.id.date_detail_fragment);
    //update the detail fragment with data from date with given id
    ddf.updateDateId(dateId);/*from  w w  w .j a  va  2s .c o m*/
}

From source file:com.android.calendar.alerts.DismissAlarmsService.java

@Override
public void onHandleIntent(Intent intent) {

    long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1);
    long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1);
    long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1);
    boolean showEvent = intent.getBooleanExtra(AlertUtils.SHOW_EVENT_KEY, false);
    long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY);
    long[] eventStarts = intent.getLongArrayExtra(AlertUtils.EVENT_STARTS_KEY);
    int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1);
    List<AlarmId> alarmIds = new LinkedList<AlarmId>();

    Uri uri = CalendarAlerts.CONTENT_URI;
    String selection;/*  ww  w . j  a va2s  .c  o  m*/

    // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms
    if (eventId != -1) {
        alarmIds.add(new AlarmId(eventId, eventStart));
        selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID
                + "=" + eventId;
    } else if (eventIds != null && eventIds.length > 0 && eventStarts != null
            && eventIds.length == eventStarts.length) {
        selection = buildMultipleEventsQuery(eventIds);
        for (int i = 0; i < eventIds.length; i++) {
            alarmIds.add(new AlarmId(eventIds[i], eventStarts[i]));
        }
    } else {
        // NOTE: I don't believe that this ever happens.
        selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED;
    }

    GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds);

    ContentResolver resolver = getContentResolver();
    ContentValues values = new ContentValues();
    values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED);
    resolver.update(uri, values, selection, null);

    // Remove from notification bar.
    if (notificationId != -1) {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(notificationId);
    }

    if (showEvent) {
        // Show event on Calendar app by building an intent and task stack to start
        // EventInfoActivity with AllInOneActivity as the parent activity rooted to home.
        Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd);

        TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i)
                .startActivities();
    }
}

From source file:com.musenkishi.wally.activities.MainActivity.java

@Override
protected void handleReceivedIntent(Context context, Intent intent) {
    long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0L);
    if (WallyApplication.getDownloadIDs().containsKey(id)) {
        WallyApplication.getDownloadIDs().remove(id);
        if (fileChangeReceiver != null) {
            Intent fileChangeIntent = new Intent(FileChangeReceiver.FILES_CHANGED);
            fileChangeReceiver.onReceive(context, fileChangeIntent);
        }/*  w  w w. j  av a 2s. com*/
        View heartTabImageView = tabBarView.getTab(4).getImageView();
        startHeartPopoutAnimation(heartTabImageView, Color.WHITE);
    }
}

From source file:com.alchemiasoft.book.activity.HomeActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    attachBookFragment(intent.getLongExtra(KEY_BOOK_ID, NOT_VALID));
}

From source file:android.support.v17.leanback.app.BrowseFragmentTest.java

private void initActivity(Intent intent) {
    setActivityIntent(intent);/*  www .j a  v a2s .  c o  m*/
    mActivity = getActivity();
    try {
        Thread.sleep(intent.getLongExtra(BrowseFragmentTestActivity.EXTRA_LOAD_DATA_DELAY,
                BrowseTestFragment.DEFAULT_LOAD_DATA_DELAY) + TRANSITION_LENGTH);
    } catch (InterruptedException ex) {
    }
}

From source file:android.support.v17.leanback.app.BrowseSupportFragmentTest.java

private void initActivity(Intent intent) {
    setActivityIntent(intent);/*  w ww.  j  a  v a 2s  .  c  o  m*/
    mActivity = getActivity();
    try {
        Thread.sleep(intent.getLongExtra(BrowseSupportFragmentTestActivity.EXTRA_LOAD_DATA_DELAY,
                BrowseTestSupportFragment.DEFAULT_LOAD_DATA_DELAY) + TRANSITION_LENGTH);
    } catch (InterruptedException ex) {
    }
}

From source file:ru.yandex.subtitles.service.speechkit.recognition.PartialResultBroadcastReceiver.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 && ACTION_PARTIAL_RESULT.equals(action)) {
        mPartialResultListener.onPartialResult(intent.getStringExtra(Intent.EXTRA_TEXT));
    }//w  w w. java  2 s  . c o m
}

From source file:io.github.data4all.service.MapTileService.java

private void doIntent(Intent intent) {

    if (intent != null) {
        long time = intent.getLongExtra(TIME, LASTTIME);
        if (time - LASTTIME > 5 * 60000 || MapViewActivity.UPDATECLICKABLE) {
            LASTTIME = time;/* w  w  w  .  ja v a2  s  .  c om*/
            MapViewActivity.UPDATECLICKABLE = true;
            double west = intent.getDoubleExtra(WEST, 0);
            double south = intent.getDoubleExtra(SOUTH, 0);
            double east = intent.getDoubleExtra(EAST, 0);
            double north = intent.getDoubleExtra(NORTH, 0);
            try {
                boolean empty = ChangesetUtil.getChangeSet(time, west, south, east, north).request();

                Log.d(TAG, "Check ChangeSets empty:" + empty);
                if (!empty) {
                    /*
                     * Creates a new Intent containing a Uri object
                     * BROADCAST_ACTION is a custom Intent action
                     */

                    Log.d(TAG, "New ChangeSets available");
                    Intent localIntent = new Intent(BROADCAST_MAP)
                            // Puts the status into the Intent
                            .putExtra(INTENT_UPDATE_TILES, true);
                    // Broadcasts the Intent to receivers in this app.
                    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
                }
            } catch (OsmException e) {
                Log.e(TAG, "" + e.toString());
            }
        }
    }
}

From source file:com.bitants.wally.activities.MainActivity.java

@Override
protected void handleReceivedIntent(Context context, Intent intent) {
    long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0L);
    if (WallyApplication.getDownloadIDs().containsKey(id)) {
        WallyApplication.getDownloadIDs().remove(id);
        if (fileReceiver != null) {
            Intent fileChangeIntent = new Intent(FileReceiver.GET_FILES);
            fileReceiver.onReceive(context, fileChangeIntent);
        }//from   w  w w  . j a v  a 2 s.  c om
        View heartTabImageView = tabBarView.getTab(4).getImageView();
        startHeartPopoutAnimation(heartTabImageView, Color.WHITE);
    }
}