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.shafiq.myfeedle.core.MyfeedleCreatePost.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case PHOTO://from  ww  w.  j  ava 2  s  .  c  o  m
        if (resultCode == RESULT_OK) {
            getPhoto(data.getData());
        }
        break;
    case TAGS:
        if ((resultCode == RESULT_OK) && data.hasExtra(Stags) && data.hasExtra(Accounts.SID))
            mAccountsTags.put(data.getLongExtra(Accounts.SID, Myfeedle.INVALID_ACCOUNT_ID),
                    data.getStringArrayExtra(Stags));
        break;
    }
}

From source file:net.momodalo.app.vimtouch.VimTouch.java

private void downloadFullRuntime() {

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override/*from w  w  w. j a  v  a  2s .c  o  m*/
        public void onReceive(Context context, Intent intent) {
            context.unregisterReceiver(this);
            String action = intent.getAction();
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                Query query = new Query();
                query.setFilterById(mEnqueue);
                Cursor c = mDM.query(query);
                if (c.moveToFirst()) {
                    int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
                    if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) {
                        String uriString = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
                        Intent newintent = new Intent(getApplicationContext(), InstallProgress.class);
                        newintent.setData(Uri.parse(uriString));
                        startActivity(newintent);
                    }
                }
            }
        }
    };

    registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

    mDM = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    Request request = new Request(Uri.parse("https://github.com/downloads/momodalo/vimtouch/vim.vrz"));
    mEnqueue = mDM.enqueue(request);
}

From source file:com.google.samples.apps.iosched.service.SessionAlarmService.java

@Override
protected void onHandleIntent(Intent intent) {
    mGoogleApiClient.blockingConnect(2000, TimeUnit.MILLISECONDS);
    final String action = intent.getAction();

    LOGD(TAG, "SessionAlarmService handling " + action);

    if (ACTION_SCHEDULE_ALL_STARRED_BLOCKS.equals(action)) {
        LOGD(TAG, "Scheduling all starred blocks.");
        scheduleAllStarredBlocks();//from  w w w . j  av a2 s  .  c o  m
        scheduleAllStarredSessionFeedbacks();
        return;
    } else if (ACTION_NOTIFY_SESSION_FEEDBACK.equals(action)) {
        LOGD(TAG, "Showing session feedback notification.");
        notifySessionFeedback(DEBUG_SESSION_ID.equals(intent.getStringExtra(EXTRA_SESSION_ID)));
        return;
    }

    final long sessionEnd = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_END, UNDEFINED_VALUE);
    if (sessionEnd == UNDEFINED_VALUE) {
        LOGD(TAG, "IGNORING ACTION -- missing sessionEnd parameter");
        return;
    }

    final long sessionAlarmOffset = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET,
            UNDEFINED_ALARM_OFFSET);
    LOGD(TAG, "Session alarm offset is: " + sessionAlarmOffset);

    // Feedback notifications have a slightly different set of extras.
    if (ACTION_SCHEDULE_FEEDBACK_NOTIFICATION.equals(action)) {
        final String sessionId = intent.getStringExtra(SessionAlarmService.EXTRA_SESSION_ID);
        final String sessionTitle = intent.getStringExtra(SessionAlarmService.EXTRA_SESSION_TITLE);
        if (sessionTitle == null || sessionEnd == UNDEFINED_VALUE || sessionId == null) {
            LOGE(TAG, "Attempted to schedule for feedback without providing extras.");
            return;
        }
        LOGD(TAG, "Scheduling feedback alarm for session: " + sessionTitle);
        scheduleFeedbackAlarm(sessionEnd, sessionAlarmOffset, sessionTitle);
        return;
    }

    final long sessionStart = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_START, UNDEFINED_VALUE);
    if (sessionStart == UNDEFINED_VALUE) {
        LOGD(TAG, "IGNORING ACTION -- no session start parameter.");
        return;
    }

    if (ACTION_NOTIFY_SESSION.equals(action)) {
        LOGD(TAG, "Notifying about sessions starting at " + sessionStart + " = "
                + (new Date(sessionStart)).toString());
        LOGD(TAG, "-> Alarm offset: " + sessionAlarmOffset);
        notifySession(sessionStart, sessionAlarmOffset);
    } else if (ACTION_SCHEDULE_STARRED_BLOCK.equals(action)) {
        LOGD(TAG, "Scheduling session alarm.");
        LOGD(TAG, "-> Session start: " + sessionStart + " = " + (new Date(sessionStart)).toString());
        LOGD(TAG, "-> Session end: " + sessionEnd + " = " + (new Date(sessionEnd)).toString());
        LOGD(TAG, "-> Alarm offset: " + sessionAlarmOffset);
        scheduleAlarm(sessionStart, sessionEnd, sessionAlarmOffset);
    }
}

From source file:com.nononsenseapps.notepad.ActivityMain.java

private void clearNotification(final Intent intent) {
    if (intent != null && intent.getLongExtra(NOTIFICATION_DELETE_ARG, -1) > 0) {
        Notification.deleteOrReschedule(this,
                Notification.getUri(intent.getLongExtra(NOTIFICATION_DELETE_ARG, -1)));
    }// w  w w  .ja  v  a2  s.co  m
    if (intent != null && intent.getLongExtra(NOTIFICATION_CANCEL_ARG, -1) > 0) {
        NotificationHelper.cancelNotification(this, (int) intent.getLongExtra(NOTIFICATION_CANCEL_ARG, -1));
    }

}

From source file:org.woltage.irssiconnectbot.ConsoleActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_SELECT:
        if (resultCode == Activity.RESULT_OK) {
            long pubkeyId = data.getLongExtra(PubkeyListActivity.PICKED_PUBKEY_ID, -1);
            PubkeyDatabase pubkeyDatabase = new PubkeyDatabase(this);
            PubkeyBean pubkey = pubkeyDatabase.findPubkeyById(pubkeyId);
            setupPublicKey(pubkey);//from w  w w  .  j  av  a  2s  .co m
        }
        break;
    default:
        super.onActivityResult(requestCode, resultCode, data);
        break;

    }
}

From source file:com.razza.apps.iosched.service.SessionAlarmService.java

@Override
protected void onHandleIntent(Intent intent) {
    mGoogleApiClient.blockingConnect(2000, TimeUnit.MILLISECONDS);
    final String action = intent.getAction();

    LogUtils.LOGD(TAG, "SessionAlarmService handling " + action);

    if (ACTION_SCHEDULE_ALL_STARRED_BLOCKS.equals(action)) {
        LogUtils.LOGD(TAG, "Scheduling all starred blocks.");
        scheduleAllStarredBlocks();/*from   www .j av  a2 s. c o m*/
        scheduleAllStarredSessionFeedbacks();
        return;
    } else if (ACTION_NOTIFY_SESSION_FEEDBACK.equals(action)) {
        LogUtils.LOGD(TAG, "Showing session feedback notification.");
        notifySessionFeedback(DEBUG_SESSION_ID.equals(intent.getStringExtra(EXTRA_SESSION_ID)));
        return;
    }

    final long sessionEnd = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_END, UNDEFINED_VALUE);
    if (sessionEnd == UNDEFINED_VALUE) {
        LogUtils.LOGD(TAG, "IGNORING ACTION -- missing sessionEnd parameter");
        return;
    }

    final long sessionAlarmOffset = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET,
            UNDEFINED_ALARM_OFFSET);
    LogUtils.LOGD(TAG, "Session alarm offset is: " + sessionAlarmOffset);

    // Feedback notifications have a slightly different set of extras.
    if (ACTION_SCHEDULE_FEEDBACK_NOTIFICATION.equals(action)) {
        final String sessionId = intent.getStringExtra(SessionAlarmService.EXTRA_SESSION_ID);
        final String sessionTitle = intent.getStringExtra(SessionAlarmService.EXTRA_SESSION_TITLE);
        if (sessionTitle == null || sessionEnd == UNDEFINED_VALUE || sessionId == null) {
            LogUtils.LOGE(TAG, "Attempted to schedule for feedback without providing extras.");
            return;
        }
        LogUtils.LOGD(TAG, "Scheduling feedback alarm for session: " + sessionTitle);
        scheduleFeedbackAlarm(sessionEnd, sessionAlarmOffset, sessionTitle);
        return;
    }

    final long sessionStart = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_START, UNDEFINED_VALUE);
    if (sessionStart == UNDEFINED_VALUE) {
        LogUtils.LOGD(TAG, "IGNORING ACTION -- no session start parameter.");
        return;
    }

    if (ACTION_NOTIFY_SESSION.equals(action)) {
        LogUtils.LOGD(TAG, "Notifying about sessions starting at " + sessionStart + " = "
                + (new Date(sessionStart)).toString());
        LogUtils.LOGD(TAG, "-> Alarm offset: " + sessionAlarmOffset);
        notifySession(sessionStart, sessionAlarmOffset);
    } else if (ACTION_SCHEDULE_STARRED_BLOCK.equals(action)) {
        LogUtils.LOGD(TAG, "Scheduling session alarm.");
        LogUtils.LOGD(TAG, "-> Session start: " + sessionStart + " = " + (new Date(sessionStart)).toString());
        LogUtils.LOGD(TAG, "-> Session end: " + sessionEnd + " = " + (new Date(sessionEnd)).toString());
        LogUtils.LOGD(TAG, "-> Alarm offset: " + sessionAlarmOffset);
        scheduleAlarm(sessionStart, sessionEnd, sessionAlarmOffset);
    }
}

From source file:com.handpoint.headstart.client.ui.MainActivity.java

void handleVoidOperation(Intent intent) {
    int financialTransactionType = intent.getIntExtra(HeadstartService.EXTRA_OPERATION_TYPE, -1);
    int amount = intent.getIntExtra(HeadstartService.EXTRA_PAYMENT_VALUE, 0);
    String currency = intent.getStringExtra(HeadstartService.EXTRA_PAYMENT_CURRENCY);
    String originalTransactionId = intent.getStringExtra(HeadstartService.EXTRA_PAYMENT_TRANSACTION_ID);
    Long originalId = intent.getLongExtra("com.handpoint.headstart.client.VOIDED_ID", -1);

    startPayment(financialTransactionType, amount, currency, true, originalTransactionId, originalId);
}

From source file:de.tubs.ibr.dtn.dtalkie.service.TalkieService.java

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

    if (de.tubs.ibr.dtn.Intent.RECEIVE.equals(action)) {
        try {/*from  w  ww .  j av  a  2s.  c  o m*/
            while (mClient.getSession().queryNext())
                ;
        } catch (Exception e) {
        }
        ;
    } else if (ACTION_MARK_DELIVERED.equals(action)) {
        final BundleID received = intent.getParcelableExtra("bundleid");
        try {
            mClient.getSession().delivered(received);
        } catch (Exception e) {
            Log.e(TAG, "Can not mark bundle as delivered.", e);
        }
    } else if (ACTION_PLAY.equals(action)) {
        Folder f = Folder.valueOf(intent.getStringExtra("folder"));
        Long msgid = intent.getLongExtra("message", 0L);

        // unmark the message
        mDatabase.mark(f, msgid, false);

        try {
            // prepare player
            Message msg = mDatabase.get(f, msgid);
            mPlayer.setDataSource(msg.getFile().getAbsolutePath());
            mPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
            mPlayer.prepareAsync();

            synchronized (mPlayerLock) {
                // set the player to playing
                mPlaying = true;

                // wait until the play-back is done
                while (mPlaying) {
                    mPlayerLock.wait();
                }
            }
        } catch (InterruptedException e) {
            Log.e(TAG, null, e);
        } catch (IOException e) {
            Log.e(TAG, null, e);
        }

        // mark the message as played
        mDatabase.mark(f, msgid, true);

        // remove notification is there are no more pending
        // messages
        removeNotification();
    } else if (ACTION_PLAY_NEXT.equals(action)) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TalkieService.this);
        if (prefs.getBoolean("autoplay", false) || HeadsetService.ENABLED) {
            Message next = mDatabase.nextMarked(Folder.INBOX, false);

            if (next != null) {
                Intent play_i = new Intent(TalkieService.this, TalkieService.class);
                play_i.setAction(TalkieService.ACTION_PLAY);
                play_i.putExtra("folder", Folder.INBOX.toString());
                play_i.putExtra("message", next.getId());
                startService(play_i);
            }
        }
    } else if (ACTION_RECORDED.equals(action)) {
        File recfile = (File) intent.getSerializableExtra("recfile");

        // create a new bundle
        Bundle b = new Bundle();

        // set destination
        b.setDestination((EID) intent.getSerializableExtra("destination"));

        // assign lifetime
        b.setLifetime(1800L);

        // request signing of the message
        b.set(ProcFlags.DTNSEC_REQUEST_SIGN, true);

        try {
            ParcelFileDescriptor fd = ParcelFileDescriptor.open(recfile, ParcelFileDescriptor.MODE_READ_ONLY);
            BundleID ret = mClient.getSession().send(b, fd);

            if (ret == null) {
                Log.e(TAG, "Recording sent failed");
            } else {
                Log.i(TAG, "Recording sent, BundleID: " + ret.toString());
            }

            recfile.delete();
        } catch (FileNotFoundException ex) {
            Log.e(TAG, "Can not open message file for transmission", ex);
        } catch (SessionDestroyedException ex) {
            Log.e(TAG, "DTN session has been destroyed.", ex);
        } catch (Exception e) {
            Log.e(TAG, "Unexpected exception while transmit message.", e);
        }
    } else if (ACTION_RECEIVED.equals(action)) {
        String source = intent.getStringExtra("source");
        String destination = intent.getStringExtra("destination");
        Date created = (Date) intent.getSerializableExtra("created");
        Date received = (Date) intent.getSerializableExtra("received");
        File file = (File) intent.getSerializableExtra("file");

        // add message to database
        Message msg = new Message(source, destination, file);
        msg.setCreated(created);
        msg.setReceived(received);
        mDatabase.put(Folder.INBOX, msg);

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        if (prefs.getBoolean("notification", true)) {
            // create a notification for this message
            createNotification();
        }

        Intent play_i = new Intent(TalkieService.this, TalkieService.class);
        play_i.setAction(ACTION_PLAY_NEXT);
        startService(play_i);
    }
}

From source file:com.klinker.android.twitter.activities.profile_viewer.ProfilePager.java

public void getFromIntent() {
    Intent from = getIntent();

    name = from.getStringExtra("name");
    screenName = from.getStringExtra("screenname");
    proPic = from.getStringExtra("profilePicture");
    tweetId = from.getLongExtra("tweetid", 0l);
    isRetweet = from.getBooleanExtra("retweet", false);

    if (screenName.equalsIgnoreCase(settings.myScreenName)) {
        isMyProfile = true;//from w ww . ja  va 2  s  .co  m
    }

    getUser();
}

From source file:com.studyjams.mdvideo.PlayerModule.ExoPlayerV2.PlayerActivityV2.java

/**debug?**/
//    @Override//www.  ja va2s  .c om
//    public void onClick(View view) {
//        if (view == retryButton) {
//            initializePlayer();
//        } else if (view.getParent() == debugRootView) {
//            trackSelectionHelper.showSelectionDialog(this, ((Button) view).getText(),
//                    trackSelector.getCurrentSelections().info, (int) view.getTag());
//        }
//    }

// PlaybackControlView.VisibilityListener implementation
//
//    @Override
//    public void onVisibilityChange(int visibility) {
//        debugRootView.setVisibility(visibility);
//    }

// Internal methods
private void initializePlayer() {
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    String intentType = intent.getStringExtra(CONTENT_TYPE_INTENT);

    if (Intent.ACTION_SEND.equals(action) && type.equals("video/*")) {

        mContentUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        mContentId = "";
        mContentPosition = C.TIME_UNSET;
        mSubtitleUri = null;
    } else if (intentType.equals(D.TYPE_VIDEO)) {

        mContentUri = intent.getData();
        mContentId = intent.getStringExtra(CONTENT_ID_EXTRA);
        mContentPosition = intent.getLongExtra(CONTENT_POSITION_EXTRA, 0);
        String subtitle = intent.getStringExtra(CONTENT_SUBTITLE_EXTRA);
        if (!TextUtils.isEmpty(subtitle)) {
            mSubtitleUri = Uri.parse(subtitle);
        } else {
            mSubtitleUri = null;
        }
        playerPosition = mContentPosition;
    } else if (intentType.equals(D.TYPE_SUBTITLE)) {
        mSubtitleUri = intent.getData();
    }

    if (player == null) {
        boolean preferExtensionDecoders = intent.getBooleanExtra(PREFER_EXTENSION_DECODERS, false);
        UUID drmSchemeUuid = intent.hasExtra(DRM_SCHEME_UUID_EXTRA)
                ? UUID.fromString(intent.getStringExtra(DRM_SCHEME_UUID_EXTRA))
                : null;
        DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
        if (drmSchemeUuid != null) {
            String drmLicenseUrl = intent.getStringExtra(DRM_LICENSE_URL);
            String[] keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES);
            Map<String, String> keyRequestProperties;
            if (keyRequestPropertiesArray == null || keyRequestPropertiesArray.length < 2) {
                keyRequestProperties = null;
            } else {
                keyRequestProperties = new HashMap<>();
                for (int i = 0; i < keyRequestPropertiesArray.length - 1; i += 2) {
                    keyRequestProperties.put(keyRequestPropertiesArray[i], keyRequestPropertiesArray[i + 1]);
                }
            }
            try {
                drmSessionManager = buildDrmSessionManager(drmSchemeUuid, drmLicenseUrl, keyRequestProperties);
            } catch (UnsupportedDrmException e) {
                int errorStringId = Util.SDK_INT < 18 ? R.string.error_drm_not_supported
                        : (e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                                ? R.string.error_drm_unsupported_scheme
                                : R.string.error_drm_unknown);
                showToast(errorStringId);
                return;
            }
        }

        eventLogger = new EventLogger();
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(
                BANDWIDTH_METER);
        trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory);
        trackSelector.addListener(this);
        trackSelector.addListener(eventLogger);
        trackSelectionHelper = new TrackSelectionHelper(trackSelector, videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(),
                drmSessionManager, preferExtensionDecoders);
        player.addListener(this);
        player.addListener(eventLogger);
        player.setAudioDebugListener(eventLogger);
        player.setVideoDebugListener(eventLogger);
        player.setId3Output(eventLogger);
        simpleExoPlayerView.setPlayer(player);

        //?mediaController
        controller.setPlayer(player);
        controller.setTitle(mContentUri.getLastPathSegment());

        //            if (isTimelineStatic) {
        if (playerPosition == C.TIME_UNSET) {
            player.seekToDefaultPosition(playerWindow);
        } else {
            player.seekTo(playerWindow, playerPosition);
        }
        //            }
        player.setPlayWhenReady(shouldAutoPlay);

        /**?
        debugViewHelper = new DebugTextViewHelper(player, debugTextView);
        debugViewHelper.start();**/

        playerNeedsSource = true;
    }
    if (playerNeedsSource) {
        //            String action = intent.getAction();
        Uri[] uris;
        String[] extensions;
        if (ACTION_VIEW.equals(action)) {
            //                uris = new Uri[]{intent.getData()};
            uris = new Uri[] { mContentUri };
            extensions = new String[] { intent.getStringExtra(EXTENSION_EXTRA) };
        } else if (ACTION_VIEW_LIST.equals(action)) {
            String[] uriStrings = intent.getStringArrayExtra(URI_LIST_EXTRA);
            uris = new Uri[uriStrings.length];
            for (int i = 0; i < uriStrings.length; i++) {
                uris[i] = Uri.parse(uriStrings[i]);
            }
            extensions = intent.getStringArrayExtra(EXTENSION_LIST_EXTRA);
            if (extensions == null) {
                extensions = new String[uriStrings.length];
            }
        } else {
            showToast(getString(R.string.unexpected_intent_action, action));
            return;
        }
        if (Util.maybeRequestReadExternalStoragePermission(this, uris)) {
            // The player will be reinitialized if the permission is granted.
            return;
        }
        MediaSource[] mediaSources = new MediaSource[uris.length];
        for (int i = 0; i < uris.length; i++) {
            mediaSources[i] = buildMediaSource(uris[i], extensions[i]);
        }
        MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
                : new ConcatenatingMediaSource(mediaSources);
        player.prepare(mediaSource, !isTimelineStatic, !isTimelineStatic);
        playerNeedsSource = false;
        //            updateButtonVisibilities();
    }
}