List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:bolts.AppLinkTest.java
public void testSimpleIntentWithAppLink() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); Bundle appLinkData = new Bundle(); appLinkData.putString("target_url", "http://www.example2.com"); appLinkData.putInt("version", 1); Bundle extras = new Bundle(); extras.putString("foo", "bar"); appLinkData.putBundle("extras", extras); i.putExtra("al_applink_data", appLinkData); assertEquals(Uri.parse("http://www.example2.com"), AppLinks.getTargetUrl(i)); assertNotNull(AppLinks.getAppLinkData(i)); assertNotNull(AppLinks.getAppLinkExtras(i)); assertEquals("bar", AppLinks.getAppLinkExtras(i).getString("foo")); }
From source file:com.eutectoid.dosomething.picker.FriendPickerFragment.java
@Override void logAppEvents(boolean doneButtonClicked) { AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), AccessToken.getCurrentAccessToken().getToken()); Bundle parameters = new Bundle(); // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have // dismissed us in response to selection changing, or user might have hit back button). Either way // we'll log the number of selections. String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED : AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN; parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome); parameters.putInt("num_friends_picked", getSelection().size()); logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters); }
From source file:de.mangelow.throughput.NotificationService.java
@SuppressWarnings("deprecation") private void modifyNotification(int drawable, String ticker, String title, String subtitle, Intent i) { boolean showticker = MainActivity.loadBooleanPref(context, MainActivity.SHOWTICKER, MainActivity.SHOWTICKER_DEFAULT); if (!showticker) ticker = null;//from w ww . j a v a2 s. c om NotificationManager nmanager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent pi = PendingIntent.getActivity(this, 0, i, NOTIFICATION_ID); Notification n = null; if (Build.VERSION.SDK_INT < 11) { n = new Notification(drawable, ticker, System.currentTimeMillis()); n.flags |= Notification.FLAG_NO_CLEAR; n.setLatestEventInfo(this, title, subtitle, pi); } else { if (nb == null) { nb = new Notification.Builder(context); nb.setPriority(Notification.PRIORITY_LOW); nb.setAutoCancel(true); } nb.setSmallIcon(drawable); if (ticker != null) nb.setTicker(ticker); nb.setContentTitle(title); nb.setContentText(subtitle); nb.setContentIntent(pi); n = nb.build(); n.flags = Notification.FLAG_NO_CLEAR; } nmanager.notify(NOTIFICATION_ID, n); // if (mResultReceiver != null) { Bundle bundle = new Bundle(); bundle.putInt("drawable", drawable); bundle.putString("title", title); bundle.putString("subtitle", subtitle); mResultReceiver.send(0, bundle); } }
From source file:com.wellsandwhistles.android.redditsp.fragments.PostListingFragment.java
@Override public Bundle onSaveInstanceState() { final Bundle bundle = new Bundle(); final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager(); bundle.putInt(SAVEDSTATE_FIRST_VISIBLE_POS, layoutManager.findFirstVisibleItemPosition()); return bundle; }
From source file:com.nextgis.firereporter.GetFiresService.java
public void onNewNotifictation(long subscriptionID, ScanexNotificationItem item) { String sAdds = item.GetPlace().equals("null") ? item.GetType() : item.GetPlace(); onNotify(3, item.GetShortCoordinates() + "/" + sAdds + "/" + item.GetDateAsString()); if (mScanexReceiver == null) return;//from ww w . j ava2 s . com Bundle b = new Bundle(); b.putLong(SUBSCRIPTION_ID, subscriptionID); b.putLong(NOTIFICATION_ID, item.GetId()); b.putInt(TYPE, SCANEX_NOTIFICATION); b.putParcelable(ITEM, item); mScanexReceiver.send(SERVICE_SCANEXDATA, b); mbHasChanges = true; }
From source file:com.nextgis.firereporter.HttpGetter.java
@Override protected Void doInBackground(String... urls) { if (IsNetworkAvailible(mContext)) { try {// w w w .j a va 2 s. c o m String sURL = urls[0]; httpget = new HttpGet(sURL); Log.d("MainActivity", "HTTPGet URL " + sURL); if (urls.length > 1) { httpget.setHeader("Cookie", urls[1]); } //TODO: move timeouts to parameters HttpParams httpParameters = new BasicHttpParams(); int timeoutConnection = 1500; HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); // Set the default socket timeout (SO_TIMEOUT) // in milliseconds which is the timeout for waiting for data. int timeoutSocket = 3000; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); HttpClient Client = new DefaultHttpClient(httpParameters); HttpResponse response = Client.execute(httpget); //ResponseHandler<String> responseHandler = new BasicResponseHandler(); //mContent = Client.execute(httpget, responseHandler); HttpEntity entity = response.getEntity(); Bundle bundle = new Bundle(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { bundle.putBoolean(GetFiresService.ERROR, false); mContent = EntityUtils.toString(entity); bundle.putString(GetFiresService.JSON, mContent); } else { bundle.putBoolean(GetFiresService.ERROR, true); bundle.putString(GetFiresService.ERR_MSG, response.getStatusLine().getStatusCode() + ": " + response.getStatusLine().getReasonPhrase()); } bundle.putInt(GetFiresService.SOURCE, mnType); Message msg = new Message(); msg.setData(bundle); if (mEventReceiver != null) { mEventReceiver.sendMessage(msg); } } catch (ClientProtocolException e) { mError = e.getMessage(); cancel(true); } catch (IOException e) { mError = e.getMessage(); cancel(true); } } else { Bundle bundle = new Bundle(); bundle.putBoolean(GetFiresService.ERROR, true); bundle.putString(GetFiresService.ERR_MSG, mContext.getString(R.string.noNetwork)); bundle.putInt(GetFiresService.SOURCE, mnType); Message msg = new Message(); msg.setData(bundle); if (mEventReceiver != null) { mEventReceiver.sendMessage(msg); } } return null; }
From source file:cz.muni.fi.japanesedictionary.entity.JapaneseCharacter.java
/** * Adds JapaneseCharater to given bundle. * /* ww w . j av a2 s.c o m*/ * @param bundle - bundle in which character should be saved * - in case of null empty bundle is created * @return Bundle returns bundle which contains CharacterInfo */ public Bundle createBundleFromJapaneseCharacter(Bundle bundle) { if (bundle == null) { bundle = new Bundle(); } if (this.getLiteral() != null && this.getLiteral().length() > 0) { bundle.putString(SAVE_CHARACTER_LITERAL, this.getLiteral()); } if (this.getRadicalClassic() != 0) { bundle.putInt(SAVE_CHARACTER_RADICAL, this.getRadicalClassic()); } if (this.getGrade() != 0) { bundle.putInt(SAVE_CHARACTER_GRADE, this.getGrade()); } if (this.getStrokeCount() != 0) { bundle.putInt(SAVE_CHARACTER_STROKE_COUNT, this.getStrokeCount()); } if (this.getSkip() != null && this.getSkip().length() > 0) { bundle.putString(SAVE_CHARACTER_SKIP, this.getSkip()); } if (this.getDicRef() != null && this.getDicRef().size() > 0) { bundle.putString(SAVE_CHARACTER_DIC_REF, (new JSONObject(this.getDicRef()).toString())); } if (this.getRmGroupJaOn() != null && this.getRmGroupJaOn().size() > 0) { bundle.putString(SAVE_CHARACTER_JA_ON, (new JSONArray(this.getRmGroupJaOn())).toString()); } if (this.getRmGroupJaKun() != null && this.getRmGroupJaKun().size() > 0) { bundle.putString(SAVE_CHARACTER_JA_KUN, (new JSONArray(this.getRmGroupJaKun())).toString()); } if (this.getMeaningEnglish() != null && this.getMeaningEnglish().size() > 0) { bundle.putString(SAVE_CHARACTER_ENGLISH, (new JSONArray(this.getMeaningEnglish())).toString()); } if (this.getMeaningFrench() != null && this.getMeaningFrench().size() > 0) { bundle.putString(SAVE_CHARACTER_FRENCH, (new JSONArray(this.getMeaningFrench())).toString()); } if (this.getMeaningDutch() != null && this.getMeaningDutch().size() > 0) { bundle.putString(SAVE_CHARACTER_DUTCH, (new JSONArray(this.getMeaningDutch())).toString()); } if (this.getMeaningGerman() != null && this.getMeaningGerman().size() > 0) { bundle.putString(SAVE_CHARACTER_GERMAN, (new JSONArray(this.getMeaningGerman())).toString()); } if (this.getMeaningRussian() != null && this.getMeaningRussian().size() > 0) { bundle.putString(SAVE_CHARACTER_RUSSIAN, (new JSONArray(this.getMeaningRussian())).toString()); } if (this.getNanori() != null && this.getNanori().size() > 0) { bundle.putString(SAVE_CHARACTER_NANORI, (new JSONArray(this.getNanori())).toString()); } return bundle; }
From source file:uk.bowdlerize.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_add: { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Get the layout inflater LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_add_url, null); final EditText urlET = (EditText) dialogView.findViewById(R.id.urlET); builder.setView(dialogView)//from ww w . j a va2 s.c om .setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Bundle extras = new Bundle(); Intent receiveURLIntent = new Intent(MainActivity.this, CensorCensusService.class); extras.putString("url", urlET.getText().toString()); extras.putString("hash", MD5(urlET.getText().toString())); extras.putInt("urgency", 0); extras.putBoolean("local", true); //Add our extra info if (getSharedPreferences(MainActivity.class.getSimpleName(), Context.MODE_PRIVATE) .getBoolean("sendISPMeta", true)) { WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); TelephonyManager telephonyManager = ((TelephonyManager) getSystemService( Context.TELEPHONY_SERVICE)); if (wifiMgr.isWifiEnabled() && null != wifiInfo.getSSID()) { LocalCache lc = null; Pair<Boolean, String> seenBefore = null; try { lc = new LocalCache(MainActivity.this); lc.open(); seenBefore = lc.findSSID(wifiInfo.getSSID().replaceAll("\"", "")); } catch (Exception e) { e.printStackTrace(); } if (null != lc) lc.close(); if (seenBefore.first) { extras.putString("isp", seenBefore.second); } else { extras.putString("isp", "unknown"); } try { extras.putString("sim", telephonyManager.getSimOperatorName()); } catch (Exception e) { e.printStackTrace(); } } else { try { extras.putString("isp", telephonyManager.getNetworkOperatorName()); } catch (Exception e) { e.printStackTrace(); } try { extras.putString("sim", telephonyManager.getSimOperatorName()); } catch (Exception e) { e.printStackTrace(); } } } receiveURLIntent.putExtras(extras); startService(receiveURLIntent); dialog.cancel(); } }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); return true; } } return super.onOptionsItemSelected(item); }
From source file:com.dattasmoon.pebble.plugin.EditNotificationActivity.java
public void save() { String selectedPackages = ""; ArrayList<String> tmpArray = new ArrayList<String>(); if (lvPackages == null || lvPackages.getAdapter() == null) { return;//from w w w. ja v a 2 s . c o m } for (String strPackage : ((packageAdapter) lvPackages.getAdapter()).selected) { if (!strPackage.isEmpty()) { if (!tmpArray.contains(strPackage)) { tmpArray.add(strPackage); selectedPackages += strPackage + ","; } } } tmpArray.clear(); tmpArray = null; if (!selectedPackages.isEmpty()) { selectedPackages = selectedPackages.substring(0, selectedPackages.length() - 1); } if (Constants.IS_LOGGABLE) { switch (mMode) { case OFF: Log.i(Constants.LOG_TAG, "Mode is: off"); break; case EXCLUDE: Log.i(Constants.LOG_TAG, "Mode is: exclude"); break; case INCLUDE: Log.i(Constants.LOG_TAG, "Mode is: include"); break; } Log.i(Constants.LOG_TAG, "Package list is: " + selectedPackages); } if (mode == Mode.STANDARD) { Editor editor = sharedPreferences.edit(); editor.putInt(Constants.PREFERENCE_MODE, mMode.ordinal()); editor.putString(Constants.PREFERENCE_PACKAGE_LIST, selectedPackages); editor.putString(Constants.PREFERENCE_PKG_RENAMES, arrayRenames.toString()); // we saved via the application, reset the variable if it exists editor.remove(Constants.PREFERENCE_TASKER_SET); // clear out legacy preference, if it exists editor.remove(Constants.PREFERENCE_EXCLUDE_MODE); // save! editor.commit(); // notify service via file that it needs to reload the preferences File watchFile = new File(getFilesDir() + "PrefsChanged.none"); if (!watchFile.exists()) { try { watchFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } watchFile.setLastModified(System.currentTimeMillis()); } else if (mode == Mode.LOCALE) { if (!isCanceled()) { final Intent resultIntent = new Intent(); final Bundle resultBundle = new Bundle(); // set the version, title and body resultBundle.putInt(Constants.BUNDLE_EXTRA_INT_VERSION_CODE, Constants.getVersionCode(getApplicationContext())); resultBundle.putInt(Constants.BUNDLE_EXTRA_INT_TYPE, Constants.Type.SETTINGS.ordinal()); resultBundle.putInt(Constants.BUNDLE_EXTRA_INT_MODE, mMode.ordinal()); resultBundle.putString(Constants.BUNDLE_EXTRA_STRING_PACKAGE_LIST, selectedPackages); resultBundle.putString(Constants.BUNDLE_EXTRA_STRING_PKG_RENAMES, arrayRenames.toString()); String blurb = ""; switch (mMode) { case OFF: blurb = getResources().getStringArray(R.array.mode_choices)[0]; break; case INCLUDE: blurb = getResources().getStringArray(R.array.mode_choices)[2]; break; case EXCLUDE: blurb = getResources().getStringArray(R.array.mode_choices)[1]; } Log.i(Constants.LOG_TAG, resultBundle.toString()); resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, resultBundle); resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb); setResult(RESULT_OK, resultIntent); } } }