List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:com.bakhtiyor.android.tumblr.TumblrService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Bundle extras = intent.getExtras(); if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null)) { if (extras.containsKey(KEY_EMAIL) && extras.containsKey(KEY_PASSWORD) && extras.containsKey(KEY_CAPTION) && extras.containsKey(KEY_IS_PRIVATE) && extras.containsKey(KEY_FILENAME)) { String email = extras.getString(KEY_EMAIL); String password = extras.getString(KEY_PASSWORD); String caption = extras.getString(KEY_CAPTION); boolean isPrivate = extras.getBoolean(KEY_IS_PRIVATE); String filename = extras.getString(KEY_FILENAME); uploadPhoto(email, password, caption, isPrivate, filename); }//from www. j a v a 2s . co m } stopSelf(startId); }
From source file:com.wso2.mobile.mdm.DisplayDeviceInfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_device_info); DeviceInfo deviceInfo = new DeviceInfo(DisplayDeviceInfoActivity.this); TextView device_id = (TextView) findViewById(R.id.txtId); TextView device = (TextView) findViewById(R.id.txtDevice); TextView model = (TextView) findViewById(R.id.txtModel); TextView operator = (TextView) findViewById(R.id.txtOperator); TextView sdk = (TextView) findViewById(R.id.txtSDK); TextView os = (TextView) findViewById(R.id.txtOS); TextView root = (TextView) findViewById(R.id.txtRoot); device_id.setText(getResources().getString(R.string.info_label_imei) + " " + deviceInfo.getDeviceId()); device.setText(getResources().getString(R.string.info_label_device) + " " + deviceInfo.getDevice()); model.setText(getResources().getString(R.string.info_label_model) + " " + deviceInfo.getDeviceModel()); JSONArray jsonArray = null;//w ww .j av a 2 s . c o m String operators = ""; if (deviceInfo.getNetworkOperatorName() != null) { jsonArray = deviceInfo.getNetworkOperatorName(); } for (int i = 0; i < jsonArray.length(); i++) { try { if (jsonArray.getString(i) != null) { if (i == (jsonArray.length() - 1)) { operators += jsonArray.getString(i); } else { operators += jsonArray.getString(i) + ", "; } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (operators.equals(null)) { operators = getResources().getString(R.string.info_label_no_sim); } operator.setText(getResources().getString(R.string.info_label_operator) + " " + operators); if (deviceInfo.getIMSINumber() != null) { sdk.setText(getResources().getString(R.string.info_label_imsi) + " " + deviceInfo.getIMSINumber()); } else { sdk.setText(getResources().getString(R.string.info_label_imsi) + " " + operators); } os.setText(getResources().getString(R.string.info_label_os) + " " + deviceInfo.getOsVersion()); root.setText(getResources().getString(R.string.info_label_rooted) + " " + (deviceInfo.isRooted() ? getResources().getString(R.string.info_label_rooted_answer_yes) : getResources().getString(R.string.info_label_rooted_answer_no))); Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(getResources().getString(R.string.intent_extra_from_activity))) { FROM_ACTIVITY = extras.getString(getResources().getString(R.string.intent_extra_from_activity)); } if (extras.containsKey(getResources().getString(R.string.intent_extra_regid))) { REG_ID = extras.getString(getResources().getString(R.string.intent_extra_regid)); } } }
From source file:org.mifos.androidclient.main.AccountTransactionHistoryActivity.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.transaction_history); if (bundle != null && bundle.containsKey(TransactionHistoryEntry.BUNDLE_KEY)) { mTransactionHistoryEntries = (List<TransactionHistoryEntry>) bundle .getSerializable(TransactionHistoryEntry.BUNDLE_KEY); }/*from w w w . j a va2s . c om*/ mTransactionHistoryList = (ListView) findViewById(R.id.transactionHistory_list); mAccountNumber = getIntent().getStringExtra(AbstractAccountDetails.ACCOUNT_NUMBER_BUNDLE_KEY); mAccountService = new AccountService(this); }
From source file:com.antonioleiva.materializeyourapp.MainActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("data")) { RecyclerViewAdapter adapter = new RecyclerViewAdapter( savedInstanceState.<NewsModel>getParcelableArrayList("data")); adapter.setOnItemClickListener(MainActivity.this); recyclerView.setAdapter(adapter); }//from w w w . j ava2 s. c om }
From source file:eu.masconsult.bgbanking.accounts.AccountAuthenticator.java
@Override public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account) throws NetworkErrorException { Log.v(TAG, "getAccountRemovalAllowed(account: " + account + ")"); Bundle result = super.getAccountRemovalAllowed(response, account); if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT) && !result.containsKey(AccountManager.KEY_INTENT)) { final boolean removalAllowed = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT); if (removalAllowed) { // Do my removal stuff here BankAccountManager.removeAccount(context, account); }/*from w ww . ja va 2 s .c om*/ } return result; }
From source file:com.gmail.altakey.lucene.AsyncImageLoader.java
private InputStream read(ProgressReportingInputStream.ProgressListener listener) throws FileNotFoundException { final Context context = this.view.getContext(); if (Intent.ACTION_SEND.equals(this.intent.getAction())) { final Bundle extras = this.intent.getExtras(); if (extras.containsKey(Intent.EXTRA_STREAM)) return new ProgressReportingInputStream(context.getContentResolver() .openInputStream((Uri) extras.getParcelable(Intent.EXTRA_STREAM)), listener); if (extras.containsKey(Intent.EXTRA_TEXT)) { try { final HttpGet req = new HttpGet(extras.getCharSequence(Intent.EXTRA_TEXT).toString()); return new ProgressReportingInputStream(this.httpClient.execute(req).getEntity().getContent(), listener);//from w w w . j a v a 2s . co m } catch (IllegalArgumentException e) { return null; } catch (IOException e) { return null; } } } if (Intent.ACTION_VIEW.equals(this.intent.getAction())) return new ProgressReportingInputStream( context.getContentResolver().openInputStream(this.intent.getData()), listener); return null; }
From source file:cc.softwarefactory.lokki.android.services.DataService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand invoked"); if (intent == null) { return START_STICKY; }/*from w w w . j a va 2s . com*/ // Check that intent isnt null, and service is connected to Google Play Services Bundle extras = intent.getExtras(); if (extras == null) { return START_STICKY; } if (extras.containsKey(ALARM_TIMER)) { fetchDashboard(); } else if (extras.containsKey(GET_PLACES)) { getPlaces(); } return START_STICKY; }
From source file:com.frublin.androidoauth2.Util.java
/** * Connect to an HTTP URL and return the response as a string. * * 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//from w w w.j a v a 2 s. c o m * @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; 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") + " FoursquareAndroidSDK"); 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("oauth_token")) { String decoded_token = URLDecoder.decode(params.getString("oauth_token")); params.putString("oauth_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; }
From source file:net.idlesoft.android.apps.github.activities.CreateIssue.java
@Override public void onRestoreInstanceState(final Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("titleText")) { ((EditText) findViewById(R.id.et_create_issue_title)) .setText(savedInstanceState.getString("titleText")); }/*w ww. j a va 2s .c o m*/ if (savedInstanceState.containsKey("bodyText")) { ((EditText) findViewById(R.id.et_create_issue_body)).setText(savedInstanceState.getString("bodyText")); } }
From source file:com.aafr.alfonso.sunshine.app.DetailFragment.java
@Override public void onResume() { super.onResume(); Bundle arguments = getArguments(); if (arguments != null && arguments.containsKey(DetailActivity.DATE_KEY) && mLocation != null && !mLocation.equals(Utility.getPreferredLocation(getActivity()))) { getLoaderManager().restartLoader(DETAIL_LOADER, null, this); }/*w w w. java 2 s . c o m*/ }