List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:com.aafr.alfonso.sunshine.app.DetailFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { mLocation = savedInstanceState.getString(LOCATION_KEY); }/*from ww w . ja v a 2 s . co m*/ Bundle arguments = getArguments(); if (arguments != null && arguments.containsKey(DetailActivity.DATE_KEY)) { getLoaderManager().initLoader(DETAIL_LOADER, null, this); } }
From source file:li.klass.fhem.fragments.SendCommandFragment.java
private void sendCommandIntent(String command) { final Context context = getActivity(); Intent intent = new Intent(Actions.EXECUTE_COMMAND); intent.setClass(getActivity(), SendCommandIntentService.class); intent.putExtra(BundleExtraKeys.COMMAND, command); intent.putExtra(BundleExtraKeys.RESULT_RECEIVER, new ResultReceiver(new Handler()) { @Override/*from w w w .ja v a 2 s.c o m*/ protected void onReceiveResult(int resultCode, Bundle resultData) { if (resultData != null && resultCode == ResultCodes.SUCCESS && resultData.containsKey(BundleExtraKeys.COMMAND_RESULT)) { String result = resultData.getString(BundleExtraKeys.COMMAND_RESULT); if (result == null || result.equals("")) { update(false); return; } if (isEmpty(result.replaceAll("[\\r\\n]", ""))) return; new AlertDialog.Builder(context).setTitle(R.string.command_execution_result).setMessage(result) .setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); update(false); } }).show(); } } }); getActivity().startService(intent); }
From source file:org.mifos.androidclient.main.LoanInstallmentDetailsActivity.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.loan_installment_details); if (bundle != null) { if (bundle.containsKey(LoanInstallmentDetails.BUNDLE_KEY)) { mDetails = (LoanInstallmentDetails) bundle.getSerializable(LoanInstallmentDetails.BUNDLE_KEY); }// w w w . java 2s . com } mAccountNumber = getIntent().getStringExtra(AbstractAccountDetails.ACCOUNT_NUMBER_BUNDLE_KEY); mAccountService = new AccountService(this); }
From source file:li.klass.fhem.fragments.SendCommandFragment.java
@Override public void update(boolean doUpdate) { Intent intent = new Intent(Actions.RECENT_COMMAND_LIST); intent.setClass(getActivity(), SendCommandIntentService.class); intent.putExtra(BundleExtraKeys.RESULT_RECEIVER, new ResultReceiver(new Handler()) { @Override/* www.ja va 2 s. c om*/ protected void onReceiveResult(int resultCode, Bundle resultData) { if (resultCode != ResultCodes.SUCCESS || resultData == null || !resultData.containsKey(BundleExtraKeys.RECENT_COMMANDS)) { return; } View view = getView(); if (view == null) return; recentCommands = resultData.getStringArrayList(BundleExtraKeys.RECENT_COMMANDS); recentCommandsAdapter.clear(); // careful: addAll method is only available since API level 11 (Android 3.0) for (String recentCommand : recentCommands) { recentCommandsAdapter.add(recentCommand); } recentCommandsAdapter.notifyDataSetChanged(); ListViewUtil.setHeightBasedOnChildren((ListView) view.findViewById(R.id.command_history)); getActivity().sendBroadcast(new Intent(Actions.DISMISS_EXECUTING_DIALOG)); } }); getActivity().startService(intent); }
From source file:li.barter.fragments.PasswordResetFragment.java
@Override public void onSuccess(final int requestId, final IBlRequestContract request, final ResponseInfo response) { if (requestId == RequestId.RESET_USER_PASSWORD) { final Bundle userInfo = response.responseBundle; Utils.updateUserInfoFromBundle(userInfo, true); BarterLiApplication.startChatService(); final Intent returnIntent = new Intent(); final Bundle arguments = getArguments(); if (arguments != null && arguments.containsKey(Keys.ONWARD_INTENT)) { returnIntent.putExtra(Keys.ONWARD_INTENT, arguments.getParcelable(Keys.ONWARD_INTENT)); }//w w w . j a va 2 s . c o m getActivity().setResult(ActionBarActivity.RESULT_OK, returnIntent); getActivity().finish(); } }
From source file:net.idlesoft.android.apps.github.activities.tabs.ClosedIssues.java
@Override public void onRestoreInstanceState(final Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); try {/* w ww . j a va2 s . c o m*/ if (savedInstanceState.containsKey("json")) { mJson = new JSONArray(savedInstanceState.getString("json")); } else { return; } } catch (final Exception e) { e.printStackTrace(); return; } if (mJson != null) { mAdapter.loadData(mJson); mAdapter.pushData(); } }
From source file:com.arthackday.killerapp.util.Util.java
public String getGoogleAuth(String type) { AccountManager mgr = AccountManager.get(activity); Account[] accts = mgr.getAccountsByType("com.google"); if (accts.length == 0) { return null; }/*from w ww. j ava 2 s . c o m*/ try { Account acct = accts[0]; Log.d(LOG_TAG, "acct name=" + acct.name); AccountManagerFuture<Bundle> accountManagerFuture = mgr.getAuthToken(acct, type, null, activity, null, null); Bundle authTokenBundle = accountManagerFuture.getResult(); if (authTokenBundle.containsKey(AccountManager.KEY_INTENT)) { Intent authRequestIntent = (Intent) authTokenBundle.get(AccountManager.KEY_INTENT); activity.startActivity(authRequestIntent); } return authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString(); } catch (OperationCanceledException e) { e.printStackTrace(); } catch (AuthenticatorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java
/** * {@inheritDoc}//w ww . ja va 2s.c o m */ @Override public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) { if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) { final String password = options.getString(AccountManager.KEY_PASSWORD); final Bundle verified = onlineConfirmPassword(account, password); final Bundle result = new Bundle(); result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null); return result; } // Launch AuthenticatorActivity to confirm credentials final Intent intent = getAuthenticator(mContext); intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_USERNAME, account.name); intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, true); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; }
From source file:edu.mit.mobile.android.locast.accounts.Authenticator.java
/** * {@inheritDoc}//ww w . j a v a 2s. c om */ @Override public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) { if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) { final String password = options.getString(AccountManager.KEY_PASSWORD); final Bundle verified = onlineConfirmPassword(account, password); final Bundle result = new Bundle(); result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null); return result; } // Launch AuthenticatorActivity to confirm credentials final Intent intent = new Intent(mContext, AuthenticatorActivity.class); intent.putExtra(AuthenticatorActivity.EXTRA_USERNAME, account.name); intent.putExtra(AuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, true); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; }
From source file:com.geozen.demo.foursquare.jiramot.Util.java
/** * Connect to an HTTP URL and return the response as a string. * /*from w w w. j av a 2 s.co m*/ * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url * - the resource to open: must be a welformed URL * @param method * - the HTTP method to use ("GET", "POST", etc.) * @param params * - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String * @throws MalformedURLException * - if the URL format is invalid * @throws IOException * - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Foursquare-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " GeoZen"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }