List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:com.halzhang.android.apps.startupnews.ui.tablet.DiscussFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);/*from w ww . j a v a2 s.c o m*/ View view = inflater.inflate(R.layout.fragment_discuss, null); mListView = (ListView) view.findViewById(android.R.id.list); mListView.setOnItemClickListener(this); mSnDiscuss = new SNDiscuss(); Bundle args = getArguments(); SNNew snNew = null; if (args != null && args.containsKey(DiscussActivity.ARG_DISCUSS_URL)) { mDiscussURL = args.getString(DiscussActivity.ARG_DISCUSS_URL); } else { throw new IllegalArgumentException("Discuss URL is required!"); } if (args.containsKey(DiscussActivity.ARG_SNNEW)) { snNew = (SNNew) args.getSerializable(DiscussActivity.ARG_SNNEW); mSnDiscuss.setSnNew(snNew); } mAdapter = new DiscussCommentAdapter(); View headerView = inflater.inflate(R.layout.discuss_header_view, null); mTitle = (TextView) headerView.findViewById(R.id.discuss_news_title); mSubTitle = (TextView) headerView.findViewById(R.id.discuss_news_subtitle); mText = (TextView) headerView.findViewById(R.id.discuss_text); mSendBtn = (ImageButton) view.findViewById(R.id.discuss_comment_send_btn); mSendBtn.setEnabled(false); mSendBtn.setOnClickListener(mSendBtnClickListener); mCommentEdit = (EditText) view.findViewById(R.id.discuss_comment_edit); mCommentEdit.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { mSendBtn.setEnabled(s.length() > 0); } }); mListView.addHeaderView(headerView); mListView.setAdapter(mAdapter); wrapHeaderView(snNew); loadData(); return view; }
From source file:com.openerp.addons.note.EditNoteFragment.java
@Override public void onStart() { super.onStart(); Bundle bundle = getArguments(); if (bundle.containsKey("row_id")) { noteMemo = (EditText) rootview.findViewById(R.id.txv_editNote_Description); descriptionHeader = (TextView) rootview.findViewById(R.id.txv_editNote_Description_Heading); webViewpad = (WebView) rootview.findViewById(R.id.txv_editNote_Description_Pad); row_id = bundle.getInt("row_id"); stageid = bundle.getString("stage_id"); tagid = bundle.getString("tag_id"); setNoteTags(tagid);/*from w ww .j a v a 2 s. co m*/ setCurrentNoteStages(scope.context()); originalMemo = bundle.getString("row_details"); // If Pad Installed if (originalMemo == null) { padAdded = true; noteMemo.setVisibility(View.GONE); descriptionHeader.setVisibility(View.GONE); originalMemo = bundle.getString("padurl"); webViewpad.setVisibility(View.VISIBLE); webViewpad.getSettings().setJavaScriptEnabled(true); webViewpad.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webViewpad.loadUrl( originalMemo + "?showChat=false&userName=" + OEUser.current(scope.context()).getUsername()); } noteMemo.setText(bundle.getString("row_details")); } }
From source file:org.mifos.androidclient.templates.OperationFormActivity.java
@Override protected void onRestoreInstanceState(Bundle bundle) { super.onRestoreInstanceState(bundle); if (bundle != null && bundle.containsKey(PREVIOUS_STATE_BUNDLE_KEY)) { mPreviousResult = (Map<String, String>) bundle.get(PREVIOUS_STATE_BUNDLE_KEY); updateViewForResponse(mPreviousResult); }/*from w w w . j a v a 2s .c om*/ }
From source file:cl.chileagil.agileday2012.fragment.MainFragment.java
void gotAccount() { Account account = accountManager.getAccountByName(accountName); if (account == null) { chooseAccount();/*from w w w . ja v a2 s . co m*/ return; } if (authToken != null) { //Ya tengo elegido mi cuenta. //Solo si no tengo datos en la DB, lo pido, sino cargo lo que hay //y actualizo solo a peticion del usuario DatabaseAdapter dbAdapter = null; try { dbAdapter = new DatabaseAdapter(this); dbAdapter.open(); if (dbAdapter.fetchCountEvents() <= 0) { onAuthToken(); } } catch (Exception e) { e.printStackTrace(); } finally { try { dbAdapter.close(); } catch (Exception e) { e.printStackTrace(); } } return; } accountManager.getAccountManager().getAuthToken(account, AUTH_TOKEN_TYPE, true, new AccountManagerCallback<Bundle>() { public void run(AccountManagerFuture<Bundle> future) { try { Bundle bundle = future.getResult(); if (bundle.containsKey(AccountManager.KEY_INTENT)) { Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intent, REQUEST_AUTHENTICATE); } else if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) { setAuthToken(bundle.getString(AccountManager.KEY_AUTHTOKEN)); onAuthToken(); } } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } }, null); }
From source file:com.wglxy.example.dashL.SearchActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SEARCH_QUERY) && savedInstanceState.containsKey(KEY_USER_OBJ)) { searchStr = savedInstanceState.getString(KEY_SEARCH_QUERY); data = savedInstanceState.getParcelableArrayList(KEY_USER_OBJ); }//from w w w . j av a2 s . c om }
From source file:com.sftoolworks.nfcoptions.SelectActivity.java
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); ListView list = (ListView) findViewById(R.id.listView1); if (list.getCount() == 0) return;//from www. j a v a 2s . c o m if (savedInstanceState.containsKey(CHECKBOX_STATE)) { boolean[] checkboxes = savedInstanceState.getBooleanArray(CHECKBOX_STATE); ((OptionListAdapter) (list.getAdapter())).restoreCheckState(checkboxes); } if (savedInstanceState.containsKey(KEY_STATE)) { selectKey = savedInstanceState.getString(KEY_STATE); } }
From source file:com.airbnb.deeplinkdispatch.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent();/*from w ww.j a va2s . c o m*/ if (intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) { String toastMessage; Bundle parameters = intent.getExtras(); Log.d(TAG, "Deeplink params: " + parameters); if (ACTION_DEEP_LINK_METHOD.equals(intent.getAction())) { toastMessage = "method with param1:" + parameters.getString("param1"); } else if (ACTION_DEEP_LINK_COMPLEX.equals(intent.getAction())) { toastMessage = parameters.getString("arbitraryNumber"); } else if (parameters.containsKey("arg")) { toastMessage = "class and found arg:" + parameters.getString("arg"); } else { toastMessage = "class"; } // You can pass a query parameter with the URI, and it's also in parameters, like // dld://classDeepLink?qp=123 if (parameters.containsKey("qp")) { toastMessage += " with query parameter " + parameters.getString("qp"); } Uri referrer = ActivityCompat.getReferrer(this); if (referrer != null) { toastMessage += " and referrer: " + referrer.toString(); } showToast(toastMessage); } }
From source file:com.google.ipc.invalidation.ticl.android.AndroidChannel.java
/** * Initiates acquisition of an authentication token that can be used with channel HTTP requests. * Android token acquisition is asynchronous since it may require HTTP interactions with the * ClientLogin servers to obtain the token. *///w w w .j a v a2 s . c om @SuppressWarnings("deprecation") synchronized void requestAuthToken(final CompletionCallback callback) { // If there is currently no token and no pending request, initiate one. if (disableAccountManager) { logger.fine("Not requesting auth token since account manager disabled"); return; } if (authToken == null) { // Ask the AccountManager for the token, with a pending future to store it on the channel // once available. final AndroidChannel theChannel = this; AccountManager accountManager = AccountManager.get(proxy.getService()); accountManager.getAuthToken(proxy.getAccount(), proxy.getAuthType(), true, new AccountManagerCallback<Bundle>() { @Override public void run(AccountManagerFuture<Bundle> future) { try { Bundle result = future.getResult(); if (result.containsKey(AccountManager.KEY_INTENT)) { // TODO: Handle case where there are no authentication // credentials associated with the client account logger.severe("Token acquisition requires user login"); callback.success(); // No further retries. } setAuthToken(result.getString(AccountManager.KEY_AUTHTOKEN)); } catch (OperationCanceledException exception) { logger.warning("Auth cancelled", exception); // TODO: Send error to client } catch (AuthenticatorException exception) { logger.warning("Auth error acquiring token", exception); callback.failure(); } catch (IOException exception) { logger.warning("IO Exception acquiring token", exception); callback.failure(); } } }, null); } else { logger.fine("Auth token request already pending"); callback.success(); } }
From source file:cc.softwarefactory.lokki.android.androidServices.LocationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand invoked"); if (intent == null) { return START_STICKY; }/* w w w . j a va2 s .com*/ Bundle extras = intent.getExtras(); if (extras == null) { return START_STICKY; } if (extras.containsKey(RUN_1_MIN)) { Log.d(TAG, "onStartCommand RUN_1_MIN"); setTemporalTimer(); } else if (extras.containsKey(ALARM_TIMER)) { Log.d(TAG, "onStartCommand ALARM_TIMER"); stopSelf(); } return START_STICKY; }
From source file:edu.stanford.junction.android.AndroidJunctionMaker.java
/** * Junction creator from a bundle passed from * a Junction Activity Director.//from w w w. j a va2 s. c o m * * The bundle may contain the URI of an existing activity session * or an activity script for creating a new session. It may also * contain casting information. * * @param bundle * @param actor * @return */ public Junction newJunction(Bundle bundle, JunctionActor actor) throws JunctionException { if (bundle == null || !bundle.containsKey(Intents.EXTRA_JUNCTION_VERSION)) { Log.d("junction", "Could not launch from bundle (" + bundle + ")"); return null; } try { if (bundle.containsKey(Intents.EXTRA_ACTIVITY_SESSION_URI)) { // TODO: pass both activity script and uri if available? // TODO: still support casting? Log.d("junction", "joining existing session " + bundle.getString(Intents.EXTRA_ACTIVITY_SESSION_URI)); URI uri = new URI(bundle.getString(Intents.EXTRA_ACTIVITY_SESSION_URI)); Junction jx = newJunction(uri, actor); return jx; } else { JSONObject desc = new JSONObject(bundle.getString(Intents.EXTRA_ACTIVITY_SCRIPT)); ActivityScript activityDesc = new ActivityScript(desc); Junction jx; if (bundle.containsKey(Intents.EXTRA_CAST_ROLES)) { Log.d("junction", "casting roles"); String[] aroles = bundle.getStringArray(AndroidJunctionMaker.Intents.EXTRA_CAST_ROLES); String[] adirectors = bundle.getStringArray(AndroidJunctionMaker.Intents.EXTRA_CAST_DIRECTORS); List<String> roles = Arrays.asList(aroles); List<URI> directors = new LinkedList<URI>(); for (int i = 0; i < adirectors.length; i++) { directors.add(new URI(adirectors[i])); } Log.d("junction", "going to request casting for " + directors.size() + " roles"); Cast support = new Cast(roles, directors); jx = newJunction(activityDesc, actor, support); } else { jx = newJunction(activityDesc, actor); } return jx; } } catch (JunctionException e) { throw e; } catch (Exception e) { e.printStackTrace(System.err); throw new JunctionException(e); } }