Example usage for android.content Intent getBooleanExtra

List of usage examples for android.content Intent getBooleanExtra

Introduction

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

Prototype

public boolean getBooleanExtra(String name, boolean defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.contralabs.inmap.activities.MainActivity.java

private boolean verifyIntentSearch(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        EasyTracker.getTracker().sendEvent("UserAction", "Search", query, 0l);
        if (query.length() > 2 && query.endsWith("s")) // To search plurals as singular (pt)
            query = query.substring(0, query.length() - 1);
        mStoreListFragment.setStoreParameters(new StoreParameters().setText(query));
        if (!isLeftMenuShowing())
            toggleList();/*from ww  w.  java2  s. co  m*/
        if (!isShowingStoreList)
            showStoreList();
        mDbAdapter.open();
        try {
            mDbAdapter.saveSearchPerformed(null, query); // FIXME Get facebook id if logged in
        } finally {
            mDbAdapter.close();
        }
        return true;
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // Handle a suggestions click (because the suggestions all use ACTION_VIEW)
        long id = Long.parseLong(intent.getDataString());
        Store store;
        mDbAdapter.open();
        try {
            store = mDbAdapter.getStore(id);
        } finally {
            mDbAdapter.close();
        }
        onStoreSelected(store);
        return true;
    } else if (intent.getBooleanExtra(SHOW_SEARCH, false)) {
        onSearchClicked();
        return true;
    }
    return false;
}

From source file:com.vanco.abplayer.BiliVideoViewActivity.java

private void parseIntent(Intent i) {
    //      Uri dat = IntentHelper.getIntentUri(i);
    //      if (dat == null)
    //         resultFinish(RESULT_FAILED);
    ////  w ww. ja  va 2  s.  co m
    //      String datString = dat.toString();
    //      if (!datString.equals(dat.toString()))
    //         dat = Uri.parse(datString);
    //
    //      mUri = dat;
    //      danmakuPath = "http://comment.bilibili.com/"+i.getStringExtra("CID")+".xml";
    //        Logger.d(danmakuPath);
    av = i.getStringExtra("av");
    page = i.getStringExtra("page");
    Logger.d("----->" + av + "/" + page);

    mNeedLock = i.getBooleanExtra("lockScreen", false);
    mDisplayName = i.getStringExtra("displayName");
    mFromStart = i.getBooleanExtra("fromStart", false);
    mSaveUri = i.getBooleanExtra("saveUri", true);
    mStartPos = i.getFloatExtra("startPosition", -1.0f);
    mLoopCount = i.getIntExtra("loopCount", 1);
    mParentId = i.getIntExtra("parentId", 0);
    mSubPath = i.getStringExtra("subPath");
    mSubShown = i.getBooleanExtra("subShown", true);
    mIsHWCodec = i.getBooleanExtra("hwCodec", false);
    Log.i("L: %b, N: %s, S: %b, P: %f, LP: %d", mNeedLock, mDisplayName, mFromStart, mStartPos, mLoopCount);
}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

private void buildDefaultState() {
    mState = new State();

    final Intent intent = virtualIntent;
    final String action = intent.getAction();
    if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) {
        mState.action = ACTION_OPEN;//  ww  w . j  av a2 s .  co  m
    } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) {
        mState.action = ACTION_CREATE;
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
        mState.action = ACTION_GET_CONTENT;
    } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
        mState.action = ACTION_MANAGE;
    }

    if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
        mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
    }

    if (mState.action == ACTION_MANAGE) {
        mState.acceptMimes = new String[] { "*/*" };
        mState.allowMultiple = true;
    } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) {
        mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES);
    } else {
        mState.acceptMimes = new String[] { intent.getType() };
    }

    mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
    mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
    mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this);
}

From source file:mobi.omegacentauri.ptimer.PTimerEditActivity.java

/** Called with the activity is first created. */
@Override//from  www  .j  av a  2  s .c  o  m
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mRecordingFilename = null;
    mRecordingUri = null;
    mPlayer = null;
    mIsPlaying = false;

    Intent intent = getIntent();

    if (intent.getBooleanExtra("privacy", false)) {
        showServerPrompt(true);
        return;
    }

    // If the Ringdroid media select activity was launched via a
    // GET_CONTENT intent, then we shouldn't display a "saved"
    // message when the user saves, we should just return whatever
    // they create.
    mWasGetContentIntent = intent.getBooleanExtra("was_get_content_intent", false);

    mFilename = intent.getData().toString();

    mSoundFile = null;
    mKeyDown = false;

    if (mFilename.equals("record")) {
        try {
            Intent recordIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
            startActivityForResult(recordIntent, REQUEST_CODE_RECORD);
        } catch (Exception e) {
            showFinalAlert(e, R.string.record_error);
        }
    }

    mHandler = new Handler();

    loadGui();

    mHandler.postDelayed(mTimerRunnable, 100);

    if (!mFilename.equals("record")) {
        loadFromFile();
    }
}

From source file:com.SpeechEd.SpeechEdEditActivity.java

/** Called with the activity is first created. */
@Override//  w ww  .j av a  2  s.  c  o m
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mRecordingFilename = null;
    mRecordingUri = null;
    mPlayer = null;
    mIsPlaying = false;

    Intent intent = getIntent();

    if (intent.getBooleanExtra("privacy", false)) {
        showServerPrompt(true);
        return;
    }

    // If the SpeechEd media select activity was launched via a
    // GET_CONTENT intent, then we shouldn't display a "saved"
    // message when the user saves, we should just return whatever
    // they create.
    mWasGetContentIntent = intent.getBooleanExtra("was_get_content_intent", false);

    mFilename = intent.getData().toString();

    mSoundFile = null;
    mKeyDown = false;

    if (mFilename.equals("record")) {
        try {
            Intent recordIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
            startActivityForResult(recordIntent, REQUEST_CODE_RECORD);
        } catch (Exception e) {
            showFinalAlert(e, R.string.record_error);
        }
    }

    mHandler = new Handler();

    loadGui();

    mHandler.postDelayed(mTimerRunnable, 100);

    if (!mFilename.equals("record")) {
        loadFromFile();
    }
}

From source file:com.ferdi2005.secondgram.voip.VoIPService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (sharedInstance != null) {
        FileLog.e("Tried to start the VoIP service when it's already started");
        return START_NOT_STICKY;
    }//from   w  w w  .  j av  a2s  .  c o  m
    userID = intent.getIntExtra("user_id", 0);
    isOutgoing = intent.getBooleanExtra("is_outgoing", false);
    user = MessagesController.getInstance().getUser(userID);

    if (user == null) {
        FileLog.w("VoIPService: user==null");
        stopSelf();
        return START_NOT_STICKY;
    }

    if (isOutgoing) {
        startOutgoingCall();
        if (intent.getBooleanExtra("start_incall_activity", false)) {
            startActivity(new Intent(this, VoIPActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }
    } else {
        NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeInCallActivity);
        call = callIShouldHavePutIntoIntent;
        callIShouldHavePutIntoIntent = null;
        acknowledgeCallAndStartRinging();
    }
    sharedInstance = this;

    return START_NOT_STICKY;
}

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

/**debug?**/
//    @Override//  w  w w . j  av  a  2 s. 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();
    }
}

From source file:com.android.contacts.ContactSaveService.java

private void setSendToVoicemail(Intent intent) {
    Uri contactUri = intent.getParcelableExtra(EXTRA_CONTACT_URI);
    boolean value = intent.getBooleanExtra(EXTRA_SEND_TO_VOICEMAIL_FLAG, false);
    if (contactUri == null) {
        Log.e(TAG, "Invalid arguments for setRedirectToVoicemail");
        return;/* w w  w.j ava 2  s.  c  o m*/
    }

    final ContentValues values = new ContentValues(1);
    values.put(Contacts.SEND_TO_VOICEMAIL, value);
    getContentResolver().update(contactUri, values, null, null);
}

From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    L.i("ServiceActionMenuActivity.onCreate");
    setContentView(R.layout.service_action_menu);
    Intent intent = getIntent();
    email = intent.getStringExtra(SERVICE_EMAIL);
    page = intent.getIntExtra(MENU_PAGE, 0);
    activity = (RelativeLayout) findViewById(R.id.activity);
    title = (TextView) findViewById(R.id.title);
    badge = (TextView) findViewById(R.id.badge);
    branding = (WebView) findViewById(R.id.branding);
    branding.setWebViewClient(new WebViewClient() {

        @Override//from  w ww .j  av a2 s.c  o m
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.startsWith("tel:")) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(intent);
                return true;
            }
            return false;
        }

    });
    pages = (LinearLayout) findViewById(R.id.pages);
    Resources resources = getResources();
    darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark);
    lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light);

    if (intent.getBooleanExtra(SHOW_ERROR_POPUP, false))
        UIUtils.showAlertDialog(this, null, R.string.error_please_try_again);

    findViewById(R.id.navigation_bar_home_button).setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            long currentTime = System.currentTimeMillis();
            if (getLastTimeClicked() != 0
                    && currentTime < (getLastTimeClicked() + ServiceBoundActivity.DOUBLE_CLICK_TIMESPAN)) {
                L.d("ignoring click on home");
                return;
            }
            setLastTimeClicked(currentTime);
            Intent i = new Intent(ServiceActionMenuActivity.this, HomeActivity.class);
            i.setFlags(MainActivity.FLAG_CLEAR_STACK);
            startActivity(i);
            finish();
        }
    });

    goToMessagingActivityIfNeeded(intent);
}

From source file:com.android.contacts.ContactSaveService.java

private void setStarred(Intent intent) {
    Uri contactUri = intent.getParcelableExtra(EXTRA_CONTACT_URI);
    boolean value = intent.getBooleanExtra(EXTRA_STARRED_FLAG, false);
    if (contactUri == null) {
        Log.e(TAG, "Invalid arguments for setStarred request");
        return;/*from   w w  w .  jav  a  2s .com*/
    }

    final ContentValues values = new ContentValues(1);
    values.put(Contacts.STARRED, value);
    getContentResolver().update(contactUri, values, null, null);

    // Undemote the contact if necessary
    final Cursor c = getContentResolver().query(contactUri, new String[] { Contacts._ID }, null, null, null);
    if (c == null) {
        return;
    }
    try {
        if (c.moveToFirst()) {
            final long id = c.getLong(0);

            // Don't bother undemoting if this contact is the user's profile.
            if (id < Profile.MIN_ID) {
                PinnedPositionsCompat.undemote(getContentResolver(), id);
            }
        }
    } finally {
        c.close();
    }
}