List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key, boolean defaultValue)
From source file:com.adam.aslfms.service.ScrobblingService.java
private void handleCommand(Intent i, int startId) { if (i == null) { Log.e(TAG, "got null intent"); return;//from w w w. j a v a 2 s. c o m } String action = i.getAction(); Bundle extras = i.getExtras(); if (action.equals(ACTION_CLEARCREDS)) { if (extras.getBoolean("clearall", false)) { mNetManager.launchClearAllCreds(); } else { String snapp = extras.getString("netapp"); if (snapp != null) { mNetManager.launchClearCreds(NetApp.valueOf(snapp)); } else Log.e(TAG, "launchClearCreds got null napp"); } } else if (action.equals(ACTION_AUTHENTICATE)) { String snapp = extras.getString("netapp"); if (snapp != null) mNetManager.launchAuthenticator(NetApp.valueOf(snapp)); else { Log.e(TAG, "launchHandshaker got null napp"); mNetManager.launchHandshakers(); } } else if (action.equals(ACTION_JUSTSCROBBLE)) { if (extras.getBoolean("scrobbleall", false)) { Log.d(TAG, "Scrobble All TRUE"); mNetManager.launchAllScrobblers(); } else { Log.e(TAG, "Scrobble All False"); String snapp = extras.getString("netapp"); if (snapp != null) { mNetManager.launchScrobbler(NetApp.valueOf(snapp)); } else Log.e(TAG, "launchScrobbler got null napp"); } } else if (action.equals(ACTION_PLAYSTATECHANGED)) { if (extras == null) { Log.e(TAG, "Got null extras on playstatechange"); return; } Track.State state = Track.State.valueOf(extras.getString("state")); Track track = InternalTrackTransmitter.popTrack(); if (track == null) { Log.e(TAG, "A null track got through!! (Ignoring it)"); return; } onPlayStateChanged(track, state); } else if (action.equals(ACTION_HEART)) { if (mCurrentTrack != null && mCurrentTrack.hasBeenQueued()) { try { if (mDb.fetchRecentTrack() == null) { Toast.makeText(this, this.getString(R.string.no_heart_track), Toast.LENGTH_LONG).show(); } else { mDb.loveRecentTrack(); Toast.makeText(this, this.getString(R.string.song_is_ready), Toast.LENGTH_SHORT).show(); Log.d(TAG, "Love Track Rating!"); } } catch (Exception e) { Log.e(TAG, "CAN'T COPY TRACK" + e); } } else if (mCurrentTrack != null) { mCurrentTrack.setRating(); Toast.makeText(this, this.getString(R.string.song_is_ready), Toast.LENGTH_SHORT).show(); Log.d(TAG, "Love Track Rating!"); } else { Toast.makeText(this, this.getString(R.string.no_current_track), Toast.LENGTH_SHORT).show(); } } else if (action.equals(ACTION_COPY)) { if (mCurrentTrack != null && mCurrentTrack.hasBeenQueued()) { try { Log.e(TAG, mDb.fetchRecentTrack().toString()); Track tempTrack = mDb.fetchRecentTrack(); int sdk = Build.VERSION.SDK_INT; if (sdk < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(tempTrack.getTrack() + " by " + tempTrack.getArtist() + ", " + tempTrack.getAlbum()); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("Track", tempTrack.getTrack() + " by " + tempTrack.getArtist() + ", " + tempTrack.getAlbum()); clipboard.setPrimaryClip(clip); } Log.d(TAG, "Copy Track!"); } catch (Exception e) { Toast.makeText(this, this.getString(R.string.no_copy_track), Toast.LENGTH_LONG).show(); Log.e(TAG, "CAN'T COPY TRACK" + e); } } else if (mCurrentTrack != null) { try { int sdk = Build.VERSION.SDK_INT; if (sdk < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(mCurrentTrack.getTrack() + " by " + mCurrentTrack.getArtist() + ", " + mCurrentTrack.getAlbum()); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("Track", mCurrentTrack.getTrack() + " by " + mCurrentTrack.getArtist() + ", " + mCurrentTrack.getAlbum()); clipboard.setPrimaryClip(clip); } Log.d(TAG, "Copy Track!"); } catch (Exception e) { Toast.makeText(this, this.getString(R.string.no_copy_track), Toast.LENGTH_LONG).show(); Log.e(TAG, "CAN'T COPY TRACK" + e); } } else { Toast.makeText(this, this.getString(R.string.no_current_track), Toast.LENGTH_SHORT).show(); } } else { Log.e(TAG, "Weird action in onStart: " + action); } }
From source file:com.borqs.browser.BookmarksPageCallbacks.java
/** * Create a new BrowserBookmarksPage./*from w w w .j a v a 2 s . c o m*/ */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); /* SharedPreferences prefs = BrowserSettings.getInstance().getPreferences(); try { mState = new JSONObject(prefs.getString(PREF_GROUP_STATE, "{}")); } catch (JSONException e) { // Parse failed, clear preference and start with empty state prefs.edit().remove(PREF_GROUP_STATE).apply(); } */ mState = new JSONObject(); Bundle args = getArguments(); mDisableNewWindow = args == null ? false : args.getBoolean(EXTRA_DISABLE_WINDOW, false); setHasOptionsMenu(true); if (mCallbacks == null && getActivity() instanceof CombinedBookmarksCallbacks) { mCallbacks = new CombinedBookmarksCallbackWrapper((CombinedBookmarksCallbacks) getActivity()); } }
From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java
public void restoreInstanceState(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.getBoolean(SAVE_INSTANCE_STATE_NAVIGATION_DRAWER_OPEN, false)) { drawerLayout.openDrawer(navigationView); this.openNavDrawerOnStart = true; }/*from w w w. j a va 2s. c o m*/ } }
From source file:androidx.navigation.fragment.NavHostFragment.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = requireContext(); mNavController = new NavController(context); mNavController.getNavigatorProvider().addNavigator(createFragmentNavigator()); Bundle navState = null;/*from ww w . j a va 2 s . co m*/ if (savedInstanceState != null) { navState = savedInstanceState.getBundle(KEY_NAV_CONTROLLER_STATE); if (savedInstanceState.getBoolean(KEY_DEFAULT_NAV_HOST, false)) { mDefaultNavHost = true; requireFragmentManager().beginTransaction().setPrimaryNavigationFragment(this).commit(); } } if (navState != null) { // Navigation controller state overrides arguments mNavController.restoreState(navState); } else { final Bundle args = getArguments(); final int graphId = args != null ? args.getInt(KEY_GRAPH_ID) : 0; if (graphId != 0) { mNavController.setGraph(graphId); } else { mNavController.setMetadataGraph(); } } }
From source file:com.easemob.chatuidemo.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MiPushClient.clearNotification(this); if (savedInstanceState != null && savedInstanceState.getBoolean(Constant.ACCOUNT_REMOVED, false)) { // ??home???appcrash // fragment?? DemoHelper.getInstance().logout(false, null); finish();/*from ww w .j av a2s. com*/ 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.em_activity_main); initView(); //umeng api MobclickAgent.updateOnlineConfig(this); UmengUpdateAgent.setUpdateOnlyWifi(false); UmengUpdateAgent.update(this); if (getIntent().getBooleanExtra(Constant.ACCOUNT_CONFLICT, false) && !isConflictDialogShow) { showConflictDialog(); } else if (getIntent().getBooleanExtra(Constant.ACCOUNT_REMOVED, false) && !isAccountRemovedDialogShow) { showAccountRemovedDialog(); } inviteMessgeDao = new InviteMessgeDao(this); userDao = new UserDao(this); conversationListFragment = new ConversationListFragment(); contactListFragment = new ContactListFragment(); settingFragment = new SettingsFragment(); fragments = new Fragment[] { conversationListFragment, contactListFragment, settingFragment }; // fragment getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, conversationListFragment) .add(R.id.fragment_container, contactListFragment).hide(contactListFragment) .show(conversationListFragment).commit(); // ?? DemoHelper.getInstance().registerGroupAndContactListener(); registerBroadcastReceiver(); // registerInternalDebugReceiver(); }
From source file:com.spoiledmilk.ibikecph.search.SearchAutocompleteActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_autocomplete_activiy); progressBar = (ProgressBar) findViewById(R.id.progressBar); progressBar.setVisibility(View.INVISIBLE); Bundle data = getIntent().getExtras(); if (data != null) { isA = data.getBoolean("isA", false); }//from www.j a va2 s .co m btnClose = (Button) findViewById(R.id.btnClose); btnClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { isClose = true; finishEditing(); } }); btnClear = (ImageButton) findViewById(R.id.btnClear); textSrch = (EditText) findViewById(R.id.textLocation); textSrch.addTextChangedListener(new MyTextWatcher()); textSrch.setImeActionLabel("Go", KeyEvent.KEYCODE_ENTER); textSrch.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { if (currentSelection == null && listSearch.getAdapter() != null && listSearch.getAdapter().getCount() > 0) { onItemClicked(0, false); } else if (currentSelection != null) { finishEditing(); } return true; } return false; } }); listSearch = (ListView) findViewById(R.id.listSearch); adapter = new AutocompleteAdapter(this, new ArrayList<SearchListItem>(), isA); listSearch.setAdapter(adapter); if (isA) { adapter.add(new CurrentLocation()); } listSearch.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long arg3) { onItemClicked(position, true); } }); if (data != null && data.containsKey("lastName")) { ArrayList<SearchListItem> listData = new ArrayList<SearchListItem>(); DB db = new DB(this); String reuseName = data.getString("lastName"); SearchListItem sli = db.getFavoriteByName(reuseName); if (sli != null) { listData.add(sli); } else { sli = db.getSearchHistoryByName(reuseName); if (sli != null) { listData.add(sli); } else { SharedPreferences prefs = getPreferences(MODE_PRIVATE); String nodeStr = prefs.getString("lastSearchItem", null); if (nodeStr != null) { JsonNode node = Util.stringToJsonNode(nodeStr); if (node != null) { sli = SearchListItem.instantiate(node); if (sli != null) { listData.add(sli); } } } } } db.close(); addr = AddressParser.parseAddressRegex(reuseName); adapter.updateListData(listData, AddressParser.addresWithoutNumber(reuseName), addr); textSrch.setText(reuseName); textSrch.setSelection(reuseName.length()); } }
From source file:com.google.android.apps.gutenberg.provider.SyncAdapter.java
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {//from ww w . ja v a 2s .c om String authToken = extras.getString(EXTRA_AUTH_TOKEN); if (TextUtils.isEmpty(authToken)) { Log.d(TAG, "Not authorized. Cannot sync."); return; } mApiClient.blockingConnect(5, TimeUnit.SECONDS); try { String cookie = getCookie(authToken); syncCheckins(provider, cookie); if (!extras.getBoolean(EXTRA_ONLY_CHECKINS, false)) { syncEvents(provider, cookie); } } catch (IOException e) { Log.e(TAG, "Error performing sync.", e); } }
From source file:cn.ucai.yizhesale.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*w w w .j ava2s. c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<EMUser>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? EMUser user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:com.app.uafeed.fragment.EntryFragment.java
public void setData(Uri uri) { mCurrentPagerPos = -1;/* w ww. ja va 2 s.com*/ mBaseUri = FeedData.EntryColumns.PARENT_URI(uri.getPath()); try { mInitialEntryId = Long.parseLong(uri.getLastPathSegment()); } catch (Exception unused) { mInitialEntryId = -1; } if (mBaseUri != null) { Bundle b = getActivity().getIntent().getExtras(); String whereClause = FeedData.shouldShowReadEntries(mBaseUri) || (b != null && b.getBoolean(Constants.INTENT_FROM_WIDGET, false)) ? null : EntryColumns.WHERE_UNREAD; // Load the entriesIds list. Should be in a loader... but I was too lazy to do so Cursor entriesCursor = MainApplication.getContext().getContentResolver().query(mBaseUri, EntryColumns.PROJECTION_ID, whereClause, null, EntryColumns.DATE + Constants.DB_DESC); if (entriesCursor != null && entriesCursor.getCount() > 0) { mEntriesIds = new long[entriesCursor.getCount()]; int i = 0; while (entriesCursor.moveToNext()) { mEntriesIds[i] = entriesCursor.getLong(0); if (mEntriesIds[i] == mInitialEntryId) { mCurrentPagerPos = i; // To immediately display the good entry } i++; } entriesCursor.close(); } } else { mEntriesIds = null; } mEntryPagerAdapter.notifyDataSetChanged(); if (mCurrentPagerPos != -1) { mEntryPager.setCurrentItem(mCurrentPagerPos); } }
From source file:de.electricdynamite.pasty.PastyLoader.java
public PastyLoader(Context context, int taskId, Bundle args) { super(context); if (PastySharedStatics.LOCAL_LOG == true) this.LOCAL_LOG = true; if (args == null) args = new Bundle(); this.context = context; // Restore preferences this.prefs = new PastyPreferencesProvider(context); // Create a PastyClient client = new PastyClient(prefs.getRESTBaseURL(), true); client.setUsername(prefs.getUsername()); client.setPassword(prefs.getPassword()); this.taskId = taskId; this.permitCache = args.getBoolean("permitCache", PastyLoader.CACHE_PERMITTED); }