Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

In this page you can find the example usage for android.os Bundle getBoolean.

Prototype

public boolean getBoolean(String key, boolean defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Usage

From source file:com.android.messaging.datamodel.NoConfirmationSmsSendService.java

@Override
protected void onHandleIntent(final Intent intent) {
    if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
        LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent");
    }//from  ww w.ja  v  a 2s. co m

    final String action = intent.getAction();
    if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent wrong action: " + action);
        }
        return;
    }
    final Bundle extras = intent.getExtras();
    if (extras == null) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG, "Called to send SMS but no extras");
        }
        return;
    }

    // Get all possible extras from intent
    final String conversationId = intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID);
    final String selfId = intent.getStringExtra(EXTRA_SELF_ID);
    final boolean requiresMms = intent.getBooleanExtra(UIIntents.UI_INTENT_EXTRA_REQUIRES_MMS, false);
    final String message = getText(intent, Intent.EXTRA_TEXT);
    final String subject = getText(intent, Intent.EXTRA_SUBJECT);
    final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID);

    final Uri intentUri = intent.getData();
    final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null;

    if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG, "Both conversationId and recipient(s) cannot be empty");
        }
        return;
    }

    if (extras.getBoolean("showUI", false)) {
        startActivity(new Intent(this, ConversationListActivity.class));
    } else {
        if (TextUtils.isEmpty(message)) {
            if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
                LogUtil.v(TAG, "Message cannot be empty");
            }
            return;
        }

        // TODO: it's possible that a long message would require sending it via mms,
        // but we're not testing for that here and we're sending the message as an sms.

        if (TextUtils.isEmpty(conversationId)) {
            InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject);
        } else {
            MessageData messageData = null;
            if (requiresMms) {
                if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
                    LogUtil.v(TAG, "Auto-sending MMS message in conversation: " + conversationId);
                }
                messageData = MessageData.createDraftMmsMessage(conversationId, selfId, message, subject);
            } else {
                if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
                    LogUtil.v(TAG, "Auto-sending SMS message in conversation: " + conversationId);
                }
                messageData = MessageData.createDraftSmsMessage(conversationId, selfId, message);
            }
            InsertNewMessageAction.insertNewMessage(messageData);
        }
        UpdateMessageNotificationAction.updateMessageNotification();
    }
}

From source file:com.ginstr.android.service.opencellid.upload.data.MeasurementsUploaderService.java

/**
 * checks intent configuration parameters
 * @param extras//  www. j  a v  a2s.c o m
 */
private void getExtraParameters(Bundle extras) {
    if (extras != null) {
        writeToLog("configurationReceiver.onReceive() extras : " + extras.keySet());

        if (extras != null) {
            appId = extras.getString(UploadConstants.PREF_APPID_KEY);

            if (extras.containsKey(UploadConstants.PREF_API_KEY))
                apiKey = extras.getString(UploadConstants.PREF_API_KEY);

            if (extras.containsKey(UploadConstants.PREF_OPENCELL_UPLOAD_URL_KEY))
                openCellUrl = extras.getString(UploadConstants.PREF_OPENCELL_UPLOAD_URL_KEY);

            if (extras.containsKey(UploadConstants.PREF_OPENCELL_NETWORK_UPLOAD_URL_KEY))
                networksUrl = extras.getString(UploadConstants.PREF_OPENCELL_NETWORK_UPLOAD_URL_KEY);

            testEnvironment = extras.getBoolean(UploadConstants.PREF_TEST_ENVIRONMENT_KEY,
                    UploadConstants.PREF_TEST_ENVIRONMENT);

            if (openCellUrl == null) {
                if (testEnvironment) {
                    openCellUrl = UploadConstants.OPEN_CELL_TEST_UPLOAD_URL;
                } else {
                    openCellUrl = UploadConstants.OPEN_CELL_DEFAULT_UPLOAD_URL;
                }
            }

            if (networksUrl == null) {
                if (testEnvironment) {
                    networksUrl = UploadConstants.OPENCELL_NETWORKS_TEST_UPLOAD_URL;
                } else {
                    networksUrl = UploadConstants.OPENCELL_NETWORKS_UPLOAD_URL;
                }
            }

            if (extras.containsKey(UploadConstants.PREF_NEW_DATA_CHECK_INTERVAL_KEY))
                newDataCheckInterval = extras.getLong(UploadConstants.PREF_NEW_DATA_CHECK_INTERVAL_KEY);

            if (newDataCheckInterval < UploadConstants.NEW_DATA_CHECK_INTERVAL_LONG_DEFAULT)
                newDataCheckInterval = UploadConstants.NEW_DATA_CHECK_INTERVAL_LONG_DEFAULT;

            if (extras.containsKey(UploadConstants.PREF_ONLY_WIFI_UPLOAD_KEY))
                wifiOnly = extras.getBoolean(UploadConstants.PREF_ONLY_WIFI_UPLOAD_KEY);

            // check if the maxLogFileSize parameter is provided through intent         
            if (extras.containsKey(UploadConstants.PREFKEY_MAX_LOG_SIZE_INT)) {
                maxLogFileSize = extras.getInt(UploadConstants.PREFKEY_MAX_LOG_SIZE_INT);

                mLibContext.getLogService().setMaxLogFileSize(maxLogFileSize);
            }

            // check if the logToFileEnabled parameter is provided through intent         
            if (extras.containsKey(UploadConstants.PREFKEY_LOG_TO_FILE)) {
                logToFileEnabled = extras.getBoolean(UploadConstants.PREFKEY_LOG_TO_FILE);

                mLibContext.getLogService().setFileLoggingEnabled(logToFileEnabled);
            }
        }

        writeToLog("onConfigurationReceiver ()");
        writeToLog("apiKey = " + apiKey);
        writeToLog("openCellUrl = " + openCellUrl);
        writeToLog("networks url = " + networksUrl);
        writeToLog("newDataCheckInterval = " + newDataCheckInterval);
        writeToLog("wifiOnly = " + wifiOnly);
        writeToLog("testEnvironment = " + testEnvironment);
    }
}

From source file:com.kinvey.scrumptious.SelectionFragment.java

/**
 * Resets the view to the initial defaults.
 *//*from www  .  j  a  va  2s . com*/
private void init(Bundle savedInstanceState) {
    announceButton.setEnabled(false);

    listElements = new ArrayList<BaseListElement>();

    listElements.add(new EatListElement(0));
    listElements.add(new LocationListElement(1));
    listElements.add(new PeopleListElement(2));
    listElements.add(new PictureListElement(3));

    if (savedInstanceState != null) {
        for (BaseListElement listElement : listElements) {
            listElement.restoreState(savedInstanceState);
        }
        pendingAnnounce = savedInstanceState.getBoolean(PENDING_ANNOUNCE_KEY, false);
    }

    listView.setAdapter(new ActionListAdapter(getActivity(), R.id.selection_list, listElements));

    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
        makeMeRequest(session);
        kinveyClient.user().loginFacebook(session.getAccessToken(), new KinveyUserCallback() {

            @Override
            public void onFailure(Throwable t) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onSuccess(User user) {
                // TODO Auto-generated method stub   
            }
        });
    }
}

From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    this.pendingReauthRequest = savedInstanceState.getBoolean(PENDING_REAUTH_KEY, false);
}

From source file:fr.cobaltians.cobalt.activities.CobaltActivity.java

/************************************************************************************************************************
* LIFECYCLE/*from   www  .j  a  v  a 2  s .  c  o  m*/
************************************************************************************************************************/

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

    setContentView(getLayoutToInflate());

    sActivitiesArrayList.add(this);

    Bundle bundle = getIntent().getExtras();
    Bundle extras = (bundle != null) ? bundle.getBundle(Cobalt.kExtras) : null;

    // TODO: uncomment for Bars
    /*
    if (extras != null && extras.containsKey(Cobalt.kBars)) {
    try {
        JSONObject actionBar = new JSONObject(extras.getString(Cobalt.kBars));
        setupActionBar(actionBar);
    }
    catch (JSONException exception) {
        if (Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - onCreate: action bar configuration parsing failed. " + extras.getString(Cobalt.kBars));
        exception.printStackTrace();
    }
    }
    */

    if (savedInstanceState == null) {
        CobaltFragment fragment = getFragment();

        if (fragment != null) {
            if (bundle != null) {
                if (extras != null)
                    fragment.setArguments(extras);

                mAnimatedTransition = bundle.getBoolean(Cobalt.kJSAnimated, true);

                if (mAnimatedTransition) {
                    mWasPushedAsModal = bundle.getBoolean(Cobalt.kPushAsModal, false);
                    if (mWasPushedAsModal) {
                        sWasPushedFromModal = true;
                        overridePendingTransition(R.anim.modal_open_enter, android.R.anim.fade_out);
                    } else if (bundle.getBoolean(Cobalt.kPopAsModal, false)) {
                        sWasPushedFromModal = false;
                        overridePendingTransition(android.R.anim.fade_in, R.anim.modal_close_exit);
                    } else if (sWasPushedFromModal)
                        overridePendingTransition(R.anim.modal_push_enter, R.anim.modal_push_exit);
                } else
                    overridePendingTransition(0, 0);
            }

            if (findViewById(getFragmentContainerId()) != null) {
                getSupportFragmentManager().beginTransaction().replace(getFragmentContainerId(), fragment)
                        .commit();
            } else if (Cobalt.DEBUG)
                Log.e(Cobalt.TAG, TAG + " - onCreate: fragment container not found");
        } else if (Cobalt.DEBUG)
            Log.e(Cobalt.TAG, TAG + " - onCreate: getFragment() returned null");
    }
}

From source file:com.example.scrumptious.SelectionFragment.java

/**
 * Resets the view to the initial defaults.
 *///from   ww w.jav a2 s  . c  om
private void init(Bundle savedInstanceState) {
    disableButtons();

    listElements = new ArrayList<BaseListElement>();

    listElements.add(new EatListElement(0));
    listElements.add(new LocationListElement(1));
    listElements.add(new PeopleListElement(2));
    listElements.add(new PhotoListElement(3));

    if (savedInstanceState != null) {
        for (BaseListElement listElement : listElements) {
            listElement.restoreState(savedInstanceState);
        }
        pendingAnnounce = savedInstanceState.getBoolean(PENDING_ANNOUNCE_KEY, false);
    }
    ActionListAdapter listAdapter = new ActionListAdapter(getActivity(), R.id.selection_list, listElements);
    listAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            updateShareContent();
        }
    });
    listView.setAdapter(listAdapter);

    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if (accessToken != null) {
        profilePictureView.setProfileId(accessToken.getUserId());
    }

    updateShareContent();
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle state = (savedInstanceState != null) ? savedInstanceState : getArguments();
    mTitle = state.getString(EXTRA_CONTENT_TITLE);
    mBreadcrumb = state.getString(EXTRA_CONTENT_BREADCRUMB);
    mDescription = state.getString(EXTRA_CONTENT_DESCRIPTION);
    //mIcon = state.getParcelable(EXTRA_CONTENT_ICON_RESOURCE_ID, 0);
    mIconUri = state.getParcelable(EXTRA_CONTENT_ICON_URI);
    mIconBitmap = state.getParcelable(EXTRA_CONTENT_ICON_BITMAP);
    mIconBackgroundColor = state.getInt(EXTRA_CONTENT_ICON_BACKGROUND, Color.TRANSPARENT);
    mName = state.getString(EXTRA_ACTION_NAME);
    mSelectedIndex = state.getInt(EXTRA_ACTION_SELECTED_INDEX, -1);
    mEntryTransitionPerformed = state.getBoolean(EXTRA_ENTRY_TRANSITION_PERFORMED, false);
}

From source file:heartware.com.heartware_master.FriendsFragment.java

/**
 * Resets the view to the initial defaults.
 *///from   w ww .  jav  a 2 s . c o  m
private void init(Bundle savedInstanceState) {
    bMeetup.setEnabled(false);

    listElements = new ArrayList<FB_BaseListElement>();

    listElements.add(new ExerciseListElement(0));
    listElements.add(new LocationListElement(1));
    listElements.add(new PeopleListElement(2));
    listElements.add(new PhotoListElement(3));

    if (savedInstanceState != null) {
        for (FB_BaseListElement listElement : listElements) {
            listElement.restoreState(savedInstanceState);
        }
        pendingAnnounce = savedInstanceState.getBoolean(PENDING_ANNOUNCE_KEY, false);
    }
    ActionListAdapter listAdapter = new ActionListAdapter(getActivity(), R.id.selection_list, listElements);
    listAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            updateShareContent();
        }
    });
    listView.setAdapter(listAdapter);

    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if (accessToken != null) {
        profilePictureView.setProfileId(accessToken.getUserId());
    }

    updateShareContent();
}

From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java

private void finishLoading() {
    boolean validData = !entries.isEmpty() || !albums.isEmpty();
    if (!validData) {
        setEmpty(true);/*ww w  .  j av  a2  s.  c o  m*/
    }

    if (validData) {
        recyclerView.setVisibility(View.VISIBLE);
    }

    if (albumListType == null || "starred".equals(albumListType)) {
        entryGridAdapter = new EntryGridAdapter(context, entries, getImageLoader(), largeAlbums);
        entryGridAdapter.setRemoveFromPlaylist(playlistId != null);
    } else {
        if ("alphabeticalByName".equals(albumListType)) {
            entryGridAdapter = new AlphabeticalAlbumAdapter(context, entries, getImageLoader(), largeAlbums);
        } else if ("highest".equals(albumListType)) {
            entryGridAdapter = new TopRatedAlbumAdapter(context, entries, getImageLoader(), largeAlbums);
        } else {
            entryGridAdapter = new EntryInfiniteGridAdapter(context, entries, getImageLoader(), largeAlbums);
        }

        // Setup infinite loading based on scrolling
        final EntryInfiniteGridAdapter infiniteGridAdapter = (EntryInfiniteGridAdapter) entryGridAdapter;
        infiniteGridAdapter.setData(albumListType, albumListExtra, albumListSize);

        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
                int totalItemCount = layoutManager.getItemCount();
                int lastVisibleItem;
                if (layoutManager instanceof GridLayoutManager) {
                    lastVisibleItem = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
                } else if (layoutManager instanceof LinearLayoutManager) {
                    lastVisibleItem = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
                } else {
                    return;
                }

                if (totalItemCount > 0 && lastVisibleItem >= totalItemCount - 2) {
                    infiniteGridAdapter.loadMore();
                }
            }
        });
    }
    entryGridAdapter.setOnItemClickedListener(this);
    // Always show artist if this is not a artist we are viewing
    if (!artist) {
        entryGridAdapter.setShowArtist(true);
    }
    if (topTracks || showAll) {
        entryGridAdapter.setShowAlbum(true);
    }

    // Show header if not album list type and not root and not artist
    // For Subsonic 5.1+ display a header for artists with getArtistInfo data if it exists
    boolean addedHeader = false;
    if (albumListType == null && (!artist || artistInfo != null || artistInfoDelayed != null)
            && (share == null || entries.size() != albums.size())) {
        View header = createHeader();

        if (header != null) {
            if (artistInfoDelayed != null) {
                final View finalHeader = header.findViewById(R.id.select_album_header);
                final View headerProgress = header.findViewById(R.id.header_progress);

                finalHeader.setVisibility(View.INVISIBLE);
                headerProgress.setVisibility(View.VISIBLE);

                new SilentBackgroundTask<Void>(context) {
                    @Override
                    protected Void doInBackground() throws Throwable {
                        MusicService musicService = MusicServiceFactory.getMusicService(context);
                        artistInfo = musicService.getArtistInfo(artistInfoDelayed, false, true, context, this);

                        return null;
                    }

                    @Override
                    protected void done(Void result) {
                        setupCoverArt(finalHeader);
                        setupTextDisplay(finalHeader);
                        setupButtonEvents(finalHeader);

                        finalHeader.setVisibility(View.VISIBLE);
                        headerProgress.setVisibility(View.GONE);
                    }
                }.execute();
            }

            entryGridAdapter.setHeader(header);
            addedHeader = true;
        }
    }

    int scrollToPosition = -1;
    if (lookupEntry != null) {
        for (int i = 0; i < entries.size(); i++) {
            if (lookupEntry.equals(entries.get(i).getTitle())) {
                scrollToPosition = i;
                entryGridAdapter.addSelected(entries.get(i));
                lookupEntry = null;
                break;
            }
        }
    }

    recyclerView.setAdapter(entryGridAdapter);
    fastScroller.attachRecyclerView(recyclerView);
    context.supportInvalidateOptionsMenu();

    if (scrollToPosition != -1) {
        recyclerView.scrollToPosition(scrollToPosition + (addedHeader ? 1 : 0));
    }

    Bundle args = getArguments();
    boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
    if (playAll && !restoredInstance) {
        playAll(args.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false), false, false);
    }
}

From source file:com.aibasis.parent.ui.MainActivity.java

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

    //----------------------------------------------------------
    SharePreferenceUtil sharePreferenceUtil = new SharePreferenceUtil(MainActivity.this);
    Log.i("jijun-test-parentId", sharePreferenceUtil.getParentId());
    DemoApplication.getInstance().setParentId(sharePreferenceUtil.getParentId());
    //----------------------------------------------------------

    // ?netty/*from  w w  w .  ja  va 2s  .  c o  m*/
    //startService(new Intent(NetworkIntent.ACTION_CONNECT_SESSION));

    if (savedInstanceState != null && savedInstanceState.getBoolean(Constant.ACCOUNT_REMOVED, false)) {
        // ??home???appcrash
        // fragment??
        DemoHXSDKHelper.getInstance().logout(true, null);
        finish();
        startActivity(new Intent(this, LoginActivity.class));
        return;
    } else if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) {
        // T??home???appcrash
        // fragment??
        finish();
        startActivity(new Intent(this, LoginActivity.class));
        return;
    }
    setContentView(R.layout.activity_main);
    initView();

    // MobclickAgent.setDebugMode( true );
    // --?--
    MobclickAgent.updateOnlineConfig(this);

    if (getIntent().getBooleanExtra("conflict", false) && !isConflictDialogShow) {
        showConflictDialog();
    } else if (getIntent().getBooleanExtra(Constant.ACCOUNT_REMOVED, false) && !isAccountRemovedDialogShow) {
        showAccountRemovedDialog();
    }

    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    // fragment???
    // chatHistoryFragment = new ChatHistoryFragment();
    // ?fragment
    //chatHistoryFragment = new ChatAllHistoryFragment();
    chatViewPagerFragment = new ChatViewPagerFragment();
    settingFragment = new SettingsFragment();
    knowledgeFragment = new KnowledgeViewPaperFragment();
    homeFragment = new HomeFragment();

    fragments = new Fragment[] { homeFragment, knowledgeFragment, chatViewPagerFragment, settingFragment };
    // fragment
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, homeFragment).show(homeFragment)
            .commit();

    init();
    //???
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager().asyncGetCurrentUserInfo();
}