List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key, boolean defaultValue)
From source file:com.abid_mujtaba.fetchheaders.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/* ww w . ja v a 2 s.c o m*/ if (savedInstanceState != null) // If the passed in state information bundle is non-empty we expect it to contain the saved value of fShowSeen. We also pass in a default value. { fShowSeen = savedInstanceState.getBoolean(BUNDLE_FLAG_SHOW_SEEN, false); } scrollList = (LinearLayout) findViewById(R.id.scrollList); if (mTTS == null) // If onCreate is called multiple times we do NOT want to create multiple TextToSpeech objects { mTTS = new TextToSpeech(this, this); } if (Account.numberOfAccounts() > 0) // Accounts have been specified { TextView tvEmpty = (TextView) findViewById(R.id.txtNoAccounts); // We start by removing the No Accounts view since accounts are present scrollList.removeView(tvEmpty); FragmentManager fM = getSupportFragmentManager(); FragmentTransaction fT = fM.beginTransaction(); for (int ii = 0; ii < Account.numberOfAccounts(); ii++) { String tag = "TAG_" + ii; // This is the tag we will use to get a handle on the fragment in the FragmentManager AccountFragment aF = (AccountFragment) fM.findFragmentByTag(tag); // We attempt to access the fragment via the specified tag if (aF == null) // This indicates that the Fragment does not exist yet so we create it. It has setRetainInstance(true) so it persists across configuration changes. { aF = AccountFragment.newInstance(ii); fT.add(R.id.scrollList, aF, tag); // Note: The addition to the scrollList only happens when aF == null, which happens when the persistent fragment has not been created yet } // Since Views retain state across config changes the scrollList remembers that it has fragments added to it mFragments.add(aF); } fT.commit(); } }
From source file:com.eutectoid.dosomething.SomethingFragment.java
/** * Resets the view to the initial defaults. *//* ww w. j a v a 2s. c o m*/ private void init(Bundle savedInstanceState) { disableButtons(); if (savedInstanceState != null) { pendingAnnounce = savedInstanceState.getBoolean(PENDING_ANNOUNCE_KEY, false); } AccessToken accessToken = AccessToken.getCurrentAccessToken(); if (accessToken != null) { profilePictureView.setProfileId(accessToken.getUserId()); } if (accessToken != null) { myUser = new User(accessToken.getUserId()); } updateShareContent(); }
From source file:cn.kangeqiu.kq.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.ja va 2s. 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<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); String strSearch = getResources().getString(R.string.search); query.setHint(strSearch); 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(); } }); // 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)) { // ? User user = BaseApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.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); }
From source file:com.facebook.android.friendsmash.HomeFragment.java
private void restoreState(Bundle savedInstanceState) { if (savedInstanceState != null) { pendingPost = savedInstanceState.getBoolean(PENDING_POST_KEY, false); }/*from www.j a va 2 s . c o m*/ }
From source file:cn.ucai.superwechat.ui.SettingsActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.em_fragment_conversation_settings); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;// w ww . j a v a 2 s . c om ImageView back = (ImageView) findViewById(R.id.img_back); back.setVisibility(View.VISIBLE); back.setOnClickListener(this); TextView title = (TextView) findViewById(R.id.txt_title); title.setVisibility(View.VISIBLE); title.setText(getString(R.string.set)); rl_switch_notification = (RelativeLayout) findViewById(R.id.rl_switch_notification); rl_switch_sound = (RelativeLayout) findViewById(R.id.rl_switch_sound); rl_switch_vibrate = (RelativeLayout) findViewById(R.id.rl_switch_vibrate); rl_switch_speaker = (RelativeLayout) findViewById(R.id.rl_switch_speaker); rl_switch_chatroom_leave = (RelativeLayout) findViewById(R.id.rl_switch_chatroom_owner_leave); rl_switch_delete_msg_when_exit_group = (RelativeLayout) findViewById( R.id.rl_switch_delete_msg_when_exit_group); rl_switch_auto_accept_group_invitation = (RelativeLayout) findViewById( R.id.rl_switch_auto_accept_group_invitation); rl_switch_adaptive_video_encode = (RelativeLayout) findViewById(R.id.rl_switch_adaptive_video_encode); rl_custom_server = (RelativeLayout) findViewById(R.id.rl_custom_server); notifiSwitch = (EaseSwitchButton) findViewById(R.id.switch_notification); soundSwitch = (EaseSwitchButton) findViewById(R.id.switch_sound); vibrateSwitch = (EaseSwitchButton) findViewById(R.id.switch_vibrate); speakerSwitch = (EaseSwitchButton) findViewById(R.id.switch_speaker); ownerLeaveSwitch = (EaseSwitchButton) findViewById(R.id.switch_owner_leave); switch_delete_msg_when_exit_group = (EaseSwitchButton) findViewById(R.id.switch_delete_msg_when_exit_group); switch_auto_accept_group_invitation = (EaseSwitchButton) findViewById( R.id.switch_auto_accept_group_invitation); switch_adaptive_video_encode = (EaseSwitchButton) findViewById(R.id.switch_adaptive_video_encode); logoutBtn = (Button) findViewById(R.id.btn_logout); if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) { logoutBtn.setText( getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")"); } customServerSwitch = (EaseSwitchButton) findViewById(R.id.switch_custom_server); textview1 = (TextView) findViewById(R.id.textview1); textview2 = (TextView) findViewById(R.id.textview2); blacklistContainer = (LinearLayout) findViewById(R.id.ll_black_list); // userProfileContainer = (LinearLayout) findViewById(R.id.ll_user_profile); llDiagnose = (LinearLayout) findViewById(R.id.ll_diagnose); pushNick = (LinearLayout) findViewById(R.id.ll_set_push_nick); settingsModel = SuperWeChatHelper.getInstance().getModel(); chatOptions = EMClient.getInstance().getOptions(); blacklistContainer.setOnClickListener(this); // userProfileContainer.setOnClickListener(this); rl_switch_notification.setOnClickListener(this); rl_switch_sound.setOnClickListener(this); rl_switch_vibrate.setOnClickListener(this); rl_switch_speaker.setOnClickListener(this); customServerSwitch.setOnClickListener(this); rl_custom_server.setOnClickListener(this); logoutBtn.setOnClickListener(this); llDiagnose.setOnClickListener(this); pushNick.setOnClickListener(this); rl_switch_chatroom_leave.setOnClickListener(this); rl_switch_delete_msg_when_exit_group.setOnClickListener(this); rl_switch_auto_accept_group_invitation.setOnClickListener(this); rl_switch_adaptive_video_encode.setOnClickListener(this); // the vibrate and sound notification are allowed or not? if (settingsModel.getSettingMsgNotification()) { notifiSwitch.openSwitch(); } else { notifiSwitch.closeSwitch(); } // sound notification is switched on or not? if (settingsModel.getSettingMsgSound()) { soundSwitch.openSwitch(); } else { soundSwitch.closeSwitch(); } // vibrate notification is switched on or not? if (settingsModel.getSettingMsgVibrate()) { vibrateSwitch.openSwitch(); } else { vibrateSwitch.closeSwitch(); } // the speaker is switched on or not? if (settingsModel.getSettingMsgSpeaker()) { speakerSwitch.openSwitch(); } else { speakerSwitch.closeSwitch(); } // if allow owner leave if (settingsModel.isChatroomOwnerLeaveAllowed()) { ownerLeaveSwitch.openSwitch(); } else { ownerLeaveSwitch.closeSwitch(); } // delete messages when exit group? if (settingsModel.isDeleteMessagesAsExitGroup()) { switch_delete_msg_when_exit_group.openSwitch(); } else { switch_delete_msg_when_exit_group.closeSwitch(); } if (settingsModel.isAutoAcceptGroupInvitation()) { switch_auto_accept_group_invitation.openSwitch(); } else { switch_auto_accept_group_invitation.closeSwitch(); } if (settingsModel.isAdaptiveVideoEncode()) { switch_adaptive_video_encode.openSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true); } else { switch_adaptive_video_encode.closeSwitch(); EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false); } if (settingsModel.isCustomServerEnable()) { customServerSwitch.openSwitch(); } else { customServerSwitch.closeSwitch(); } }
From source file:com.android.settings.users.RestrictedProfileSettings.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (icicle != null) { mSavedPhoto = (Bitmap) icicle.getParcelable(KEY_SAVED_PHOTO); mWaitingForActivityResult = icicle.getBoolean(KEY_AWAITING_RESULT, false); }/*from w w w . j av a 2s. c o m*/ init(icicle); }
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.ApptentiveBaseFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = getArguments(); if (bundle != null) { toolbarLayoutId = bundle.getInt(Constants.FragmentConfigKeys.TOOLBAR_ID); bShownAsModal = bundle.getBoolean(Constants.FragmentConfigKeys.MODAL, false); String interactionString = bundle.getString("interaction"); if (!TextUtils.isEmpty(interactionString)) { interaction = (T) Interaction.Factory.parseInteraction(interactionString); }/* www .j ava2s. co m*/ } if (interaction != null) { // Set the title for modal Interactions for TalkBack support here. Fullscreen Interactions will set title in the ViewPager when they page into view. if (bShownAsModal) { getActivity().setTitle(interaction.getTitle()); } else { sectionTitle = interaction.getTitle(); } } if (toolbarLayoutId != 0 && getMenuResourceId() != 0) { setHasOptionsMenu(true); } if (savedInstanceState != null) { hasLaunched = savedInstanceState.getBoolean(HAS_LAUNCHED); } if (!hasLaunched) { hasLaunched = true; sendLaunchEvent(getActivity()); } }
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;/*w w w . j av a2s .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 (!settings.getUsername(NetApp.LASTFM).equals("")) { 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 { Toast.makeText(this, this.getString(R.string.no_lastFm), Toast.LENGTH_LONG).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.imalu.alyou.activity.FriendlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from w w w .j a v a2 s . co m inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); relativeLayout = (RelativeLayout) getView().findViewById(R.id.add_friend_layout); groups = (RelativeLayout) getView().findViewById(R.id.groups); sidebar.setListView(listView); sidebar.setVisibility(ViewGroup.GONE); relativeLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent(getActivity(), FindFriendActivity.class)); } }); groups.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent(getActivity(), GroupsActivity.class)); } }); showListView(); // //??? // //blackList = EMContactManager.getInstance().getBlackListUsernames(); // contactList = new ArrayList<HXUser>(); // // ?contactlist // getContactList(); // // adapter // adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar); // 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)) { // // ? // HXUser user = AlUApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); // user.setUnreadMsgCount(0); // startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); // } else if (Constant.GROUP_USERNAME.equals(username)) { // // ?? // startActivity(new Intent(getActivity(), GroupsActivity.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); // setView(); // setLisetener(); }
From source file:com.android.browser.BookmarksPageCallbacks.java
/** * Create a new BrowserBookmarksPage.//from w w w. java 2 s. co 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()); } }