List of usage examples for android.os Bundle putLong
public void putLong(@Nullable String key, long value)
From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java
private void checkAlerts() { final PackageInfo packageInfo = getWalletApplication().packageInfo(); final int versionNameSplit = packageInfo.versionName.indexOf('-'); final String base = Constants.VERSION_URL + (versionNameSplit >= 0 ? packageInfo.versionName.substring(versionNameSplit) : ""); final String url = base + "?package=" + packageInfo.packageName + "¤t=" + packageInfo.versionCode; new HttpGetThread(getAssets(), url, application.httpUserAgent()) { @Override// ww w .ja va 2 s . co m protected void handleLine(final String line, final long serverTime) { final int serverVersionCode = Integer.parseInt(line.split("\\s+")[0]); log.info("according to \"" + url + "\", strongly recommended minimum app version is " + serverVersionCode); if (serverTime > 0) { final long diffMinutes = Math .abs((System.currentTimeMillis() - serverTime) / DateUtils.MINUTE_IN_MILLIS); if (diffMinutes >= 60) { log.info( "according to \"" + url + "\", system clock is off by " + diffMinutes + " minutes"); runOnUiThread(new Runnable() { @Override public void run() { final Bundle args = new Bundle(); args.putLong("diff_minutes", diffMinutes); showDialog(DIALOG_TIMESKEW_ALERT, args); } }); return; } } if (serverVersionCode > packageInfo.versionCode && Constants.ENABLE_VERSION_ALERT) { runOnUiThread(new Runnable() { @Override public void run() { showDialog(DIALOG_VERSION_ALERT); } }); return; } } @Override protected void handleException(final Exception x) { if (x instanceof UnknownHostException || x instanceof SocketException || x instanceof SocketTimeoutException) { // swallow log.debug("problem reading", x); } else { CrashReporter.saveBackgroundTrace(new RuntimeException(url, x), packageInfo); } } }.start(); if (CrashReporter.hasSavedCrashTrace()) { final StringBuilder stackTrace = new StringBuilder(); try { CrashReporter.appendSavedCrashTrace(stackTrace); } catch (final IOException x) { log.info("problem appending crash info", x); } final ReportIssueDialogBuilder dialog = new ReportIssueDialogBuilder(this, R.string.report_issue_dialog_title_crash, R.string.report_issue_dialog_message_crash) { @Override protected CharSequence subject() { return Constants.REPORT_SUBJECT_CRASH + " " + packageInfo.versionName; } @Override protected CharSequence collectApplicationInfo() throws IOException { final StringBuilder applicationInfo = new StringBuilder(); CrashReporter.appendApplicationInfo(applicationInfo, application); return applicationInfo; } @Override protected CharSequence collectStackTrace() throws IOException { if (stackTrace.length() > 0) return stackTrace; else return null; } @Override protected CharSequence collectDeviceInfo() throws IOException { final StringBuilder deviceInfo = new StringBuilder(); CrashReporter.appendDeviceInfo(deviceInfo, WalletActivity.this); return deviceInfo; } @Override protected CharSequence collectWalletDump() { return wallet.toString(false, true, true, null); } }; dialog.show(); } }
From source file:com.andryr.musicplayer.PlaybackService.java
private void notifyChange(String what) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { updateMediaSession(what);/*w w w . j a v a2 s.c om*/ } saveState(QUEUE_CHANGED.equals(what) || ITEM_ADDED.equals(what) || ORDER_CHANGED.equals(what)); if (PLAYSTATE_CHANGED.equals(what) || META_CHANGED.equals(what)) { Notification.updateNotification(this); // notify third party applications Intent intent = new Intent(); intent.setAction( "com.android.music." + (PLAYSTATE_CHANGED.equals(what) ? "playstatechanged" : "metachanged")); Bundle bundle = new Bundle(); // put the song's metadata bundle.putString("track", getSongTitle()); bundle.putString("artist", getArtistName()); bundle.putString("album", getAlbumName()); // put the song's total duration (in ms) bundle.putLong("duration", getTrackDuration()); // put the song's current position bundle.putLong("position", getPlayerPosition()); // put the playback status bundle.putBoolean("playing", isPlaying()); // currently playing // put your application's package bundle.putString("scrobbling_source", getPackageName()); intent.putExtras(bundle); sendBroadcast(intent); } sendBroadcast(what, null); }
From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java
private void editBookmark(BrowserBookmarksAdapter adapter, int position) { Intent intent = new Intent(this, AddBookmarkPage.class); Cursor cursor = adapter.getItem(position); Bundle item = new Bundle(); item.putString(BrowserContract.Bookmarks.TITLE, cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE)); item.putString(BrowserContract.Bookmarks.URL, cursor.getString(BookmarksLoader.COLUMN_INDEX_URL)); byte[] data = cursor.getBlob(BookmarksLoader.COLUMN_INDEX_FAVICON); if (data != null) { item.putParcelable(BrowserContract.Bookmarks.FAVICON, BitmapFactory.decodeByteArray(data, 0, data.length)); }// www. j a va2 s.c o m item.putLong(BrowserContract.Bookmarks._ID, cursor.getLong(BookmarksLoader.COLUMN_INDEX_ID)); item.putLong(BrowserContract.Bookmarks.PARENT, cursor.getLong(BookmarksLoader.COLUMN_INDEX_PARENT)); intent.putExtra(AddBookmarkPage.EXTRA_EDIT_BOOKMARK, item); intent.putExtra(AddBookmarkPage.EXTRA_IS_FOLDER, cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) == 1); startActivity(intent); }
From source file:cat.wuyingren.rorhelper.activities.MainActivity.java
/** Swaps fragments in the menu_main_complete content view */ private void selectItem(int position) { Fragment fragment = new GameListFragment(); Bundle args = new Bundle(); switch (position) { case 0:/*from ww w . j av a 2 s . co m*/ case 3: case 8: //Headers break; case 1: mTitle = getString(R.string.title_section1); fragment.setArguments(args); break; case 2: mTitle = getString(R.string.title_section2); fragment = new GameStatusFragment(); args = new Bundle(); args.putLong(GameStatusFragment.ARG_GAME_ID, currentGameId); fragment.setArguments(args); break; case 4: mTitle = getString(R.string.faction_imperials); fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle)); break; case 5: mTitle = getString(R.string.faction_plutocrats); fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle)); break; case 6: mTitle = getString(R.string.faction_conservatives); fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle)); break; case 7: mTitle = getString(R.string.faction_populists); fragment = prepareFactionFragment(dataSource.getFactionId(currentGameId, mTitle)); break; case 9: mTitle = getString(R.string.title_section3); fragment = new CardListFragment(); args = new Bundle(); args.putInt(CardListFragment.ARG_SCENARIO_ID, currentGame.getScenarioID()); args.putBoolean(CardListFragment.ARG_STATEMEN_ENABLED, false); fragment.setArguments(args); break; case 10: mTitle = getString(R.string.title_section4); fragment = new CardListFragment(); args = new Bundle(); args.putInt(CardListFragment.ARG_SCENARIO_ID, currentGame.getScenarioID()); args.putBoolean(CardListFragment.ARG_STATEMEN_ENABLED, true); fragment.setArguments(args); break; default: break; } // Insert the fragment by replacing any existing fragment FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // Highlight the selected item, update the title, and close the drawer mDrawerList.setItemChecked(position, true); //getActionBar().setTitle((mOperationsSystem[position])); mDrawerLayout.closeDrawer(mDrawerLayout.findViewById(R.id.drawerRoot)); }
From source file:com.barkside.travellocblog.LocationUpdates.java
/** * We need to survive a device orientation change. Android will completely destroy * and recreate this activity./* w w w. ja v a 2 s .co m*/ * If we don't remember mExpirationTime for example, we may restart this activity and * forget that the timer had been already set previously. */ @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); Log.d(TAG, "save instance state"); // Save UI state changes to the savedInstanceState. // This bundle will be passed to onCreate if the process is // killed and restarted. savedInstanceState.putLong("mExpirationTime", mExpirationTime); }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
@Rpc(description = "Get list of constants (static final fields) for a class") public Bundle getConstants( @RpcParameter(name = "classname", description = "Class to get constants from") String classname) throws Exception { Bundle result = new Bundle(); int flags = Modifier.FINAL | Modifier.PUBLIC | Modifier.STATIC; Class<?> clazz = Class.forName(classname); for (Field field : clazz.getFields()) { if ((field.getModifiers() & flags) == flags) { Class<?> type = field.getType(); String name = field.getName(); if (type == int.class) { result.putInt(name, field.getInt(null)); } else if (type == long.class) { result.putLong(name, field.getLong(null)); } else if (type == double.class) { result.putDouble(name, field.getDouble(null)); } else if (type == char.class) { result.putChar(name, field.getChar(null)); } else if (type instanceof Object) { result.putString(name, field.get(null).toString()); }/* ww w . j a v a 2 s. c o m*/ } } return result; }
From source file:com.eleybourn.bookcatalogue.BookEdit.java
@Override protected void onSaveInstanceState(Bundle outState) { Tracker.enterOnSaveInstanceState(this); super.onSaveInstanceState(outState); ActionBar actionBar = this.getSupportActionBar(); outState.putLong(CatalogueDBAdapter.KEY_ROWID, mRowId); outState.putBundle("bookData", mBookData.getRawData()); if (mList != null) { outState.putInt("FlattenedBooklistPosition", (int) mList.getPosition()); }/*from w w w. j av a 2s .c o m*/ outState.putInt(BookEdit.TAB, actionBar.getSelectedNavigationIndex()); Tracker.exitOnSaveInstanceState(this); }
From source file:com.gelakinetic.mtgfam.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* http://stackoverflow.com/questions/13179620/force-overflow-menu-in-actionbarsherlock/13180285 * //from w ww.ja v a 2 s . c o m * Open ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java, go to method reserveOverflow * Replace the original with: * public static boolean reserveOverflow(Context context) { return true; } */ if (DEVICE_VERSION >= DEVICE_HONEYCOMB) { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } } mFragmentManager = getSupportFragmentManager(); try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (NameNotFoundException e) { pInfo = null; } if (prefAdapter == null) { prefAdapter = new PreferencesAdapter(this); } int lastVersion = prefAdapter.getLastVersion(); if (pInfo.versionCode != lastVersion) { // Clear the robospice cache on upgrade. This way, no cached values w/o foil prices will exist try { spiceManager.removeAllDataFromCache(); } catch (NullPointerException e) { // eat it. tasty } showDialogFragment(CHANGELOGDIALOG); prefAdapter.setLastVersion(pInfo.versionCode); bounceMenu = lastVersion <= 15; //Only bounce if the last version is 1.8.1 or lower (or a fresh install) } File mtr = new File(getFilesDir(), JudgesCornerFragment.MTR_LOCAL_FILE); File ipg = new File(getFilesDir(), JudgesCornerFragment.IPG_LOCAL_FILE); if (!mtr.exists()) { try { InputStream in = getResources().openRawResource(R.raw.mtr); FileOutputStream fos = new FileOutputStream(mtr); IOUtils.copy(in, fos); } catch (FileNotFoundException e) { Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage()); } catch (IOException e) { Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage()); } } if (!ipg.exists()) { try { InputStream in = getResources().openRawResource(R.raw.ipg); FileOutputStream fos = new FileOutputStream(ipg); IOUtils.copy(in, fos); } catch (FileNotFoundException e) { Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage()); } catch (IOException e) { Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage()); } } ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setIcon(R.drawable.sliding_menu_icon); SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setBehindWidthRes(R.dimen.sliding_menu_width); slidingMenu.setBehindScrollScale(0.0f); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.sliding_menu_shadow); setSlidingActionBarEnabled(false); setBehindContentView(R.layout.fragment_menu); me = this; boolean autoupdate = prefAdapter.getAutoUpdate(); if (autoupdate) { // Only update the banning list if it hasn't been updated recently long curTime = new Date().getTime(); int updatefrequency = Integer.valueOf(prefAdapter.getUpdateFrequency()); int lastLegalityUpdate = prefAdapter.getLastLegalityUpdate(); // days to ms if (((curTime / 1000) - lastLegalityUpdate) > (updatefrequency * 24 * 60 * 60)) { startService(new Intent(this, DbUpdaterService.class)); } } timerHandler = new Handler(); registerReceiver(endTimeReceiver, new IntentFilter(RoundTimerFragment.RESULT_FILTER)); registerReceiver(startTimeReceiver, new IntentFilter(RoundTimerService.START_FILTER)); registerReceiver(cancelTimeReceiver, new IntentFilter(RoundTimerService.CANCEL_FILTER)); updatingDisplay = false; timeShowing = false; getSlidingMenu().setOnOpenedListener(new OnOpenedListener() { @Override public void onOpened() { // Close the keyboard if the slidingMenu is opened hideKeyboard(); } }); setContentView(R.layout.fragment_activity); getSupportFragmentManager().beginTransaction().replace(R.id.frag_menu, new MenuFragment()).commit(); showOnePane(); if (findViewById(R.id.middle_container) != null) { // The detail container view will be present only in the // large-screen layouts (res/values-large and // res/values-sw600dp). If this view is present, then the // activity should be in two-pane mode. mIsATablet = true; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mThreePane = true; } else { mThreePane = false; } } else { mThreePane = false; mIsATablet = false; if (findViewById(R.id.middle_container) != null) { findViewById(R.id.middle_container).setVisibility(View.GONE); findViewById(R.id.right_container).setVisibility(View.GONE); } } Intent intent = getIntent(); if (savedInstanceState == null) { try { if (intent.getAction().equals(Intent.ACTION_VIEW)) { //apparently this can NPE on 4.3. because why not. if we catch it, launch the default frag // handles a click on a search suggestion; launches activity to show word Uri u = intent.getData(); long id = Long.parseLong(u.getLastPathSegment()); // add a fragment Bundle args = new Bundle(); args.putBoolean("isSingle", true); args.putLong("id", id); CardViewFragment rlFrag = new CardViewFragment(); rlFrag.setArguments(args); attachSingleFragment(rlFrag, "left_frag", false, false); showOnePane(); hideKeyboard(); } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) { boolean consolidate = prefAdapter.getConsolidateSearch(); String query = intent.getStringExtra(SearchManager.QUERY); SearchCriteria sc = new SearchCriteria(); sc.Name = query; sc.Set_Logic = (consolidate ? CardDbAdapter.FIRSTPRINTING : CardDbAdapter.ALLPRINTINGS); // add a fragment Bundle args = new Bundle(); args.putBoolean(SearchViewFragment.RANDOM, false); args.putSerializable(SearchViewFragment.CRITERIA, sc); if (mIsATablet) { SearchViewFragment svFrag = new SearchViewFragment(); svFrag.setArguments(args); attachSingleFragment(svFrag, "left_frag", false, false); } else { ResultListFragment rlFrag = new ResultListFragment(); rlFrag.setArguments(args); attachSingleFragment(rlFrag, "left_frag", false, false); } hideKeyboard(); } else if (intent.getAction().equals(ACTION_FULL_SEARCH)) { attachSingleFragment(new SearchViewFragment(), "left_frag", false, false); showOnePane(); } else if (intent.getAction().equals(ACTION_WIDGET_SEARCH)) { attachSingleFragment(new SearchWidgetFragment(), "left_frag", false, false); showOnePane(); } else if (intent.getAction().equals(ACTION_ROUND_TIMER)) { attachSingleFragment(new RoundTimerFragment(), "left_frag", false, false); showOnePane(); } else { launchDefaultFragment(); } } catch (NullPointerException e) { launchDefaultFragment(); } } }
From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java
public boolean onContextItemSelected(MenuItem item) { if (item.getMenuInfo() != null) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); selectedPosition = info.position; }/* w ww .j a v a 2 s. c om*/ Cursor c = mAdapter.getCursor(); c.moveToPosition(selectedPosition); Channel chan = cursorToChannel(c); Timer timer; switch (item.getItemId()) { case R.id.menuTimer: timer = cursorToTimer(c); if (UIUtils.isTablet(getActivity())) { TimerDetails timerdetails = TimerDetails.newInstance(); Bundle args = new Bundle(); args.putString(TimerDetails.EXTRA_TITLE, timer.getTitle()); args.putString(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName()); args.putLong(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId()); args.putLong(TimerDetails.EXTRA_START, timer.getStart().getTime()); args.putLong(TimerDetails.EXTRA_END, timer.getEnd().getTime()); timerdetails.setArguments(args); timerdetails.show(getSherlockActivity().getSupportFragmentManager(), TimerDetails.class.getName()); } else { Intent timerIntent = new Intent(getActivity(), TimerDetailsActivity.class); timerIntent.putExtra(TimerDetails.EXTRA_TITLE, timer.getTitle()); timerIntent.putExtra(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName()); timerIntent.putExtra(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId()); timerIntent.putExtra(TimerDetails.EXTRA_START, timer.getStart().getTime()); timerIntent.putExtra(TimerDetails.EXTRA_END, timer.getEnd().getTime()); startActivity(timerIntent); } return true; case R.id.menuStream: if (UIUtils.isTablet(getActivity())) { StreamConfig cfg = StreamConfig.newInstance(); Bundle arguments = new Bundle(); arguments.putInt(StreamConfig.EXTRA_FILE_ID, chan.getPosition()); arguments.putInt(StreamConfig.EXTRA_FILE_TYPE, StreamConfig.FILE_TYPE_LIVE); arguments.putInt(StreamConfig.EXTRA_DIALOG_TITLE_RES, R.string.streamConfig); cfg.setArguments(arguments); cfg.show(getSherlockActivity().getSupportFragmentManager(), StreamConfig.class.getName()); } else { Intent streamConfig = new Intent(getActivity(), StreamConfigActivity.class); streamConfig.putExtra(StreamConfig.EXTRA_FILE_ID, chan.getPosition()); streamConfig.putExtra(StreamConfig.EXTRA_FILE_TYPE, StreamConfig.FILE_TYPE_LIVE); streamConfig.putExtra(StreamConfig.EXTRA_DIALOG_TITLE_RES, R.string.streamConfig); startActivity(streamConfig); } return true; case R.id.menuSwitch: String switchRequest = ServerConsts.URL_SWITCH_COMMAND + chan.getPosition(); DVBViewerCommand command = new DVBViewerCommand(switchRequest); Thread exexuterTHread = new Thread(command); exexuterTHread.start(); return true; case R.id.menuRecord: timer = cursorToTimer(c); String url = timer.getId() <= 0l ? ServerConsts.URL_TIMER_CREATE : ServerConsts.URL_TIMER_EDIT; String title = timer.getTitle(); String days = String.valueOf(DateUtils.getDaysSinceDelphiNull(timer.getStart())); String start = String.valueOf(DateUtils.getMinutesOfDay(timer.getStart())); String stop = String.valueOf(DateUtils.getMinutesOfDay(timer.getEnd())); String endAction = String.valueOf(timer.getTimerAction()); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("ch", String.valueOf(timer.getChannelId()))); params.add(new BasicNameValuePair("dor", days)); params.add(new BasicNameValuePair("encoding", "255")); params.add(new BasicNameValuePair("enable", "1")); params.add(new BasicNameValuePair("start", start)); params.add(new BasicNameValuePair("stop", stop)); params.add(new BasicNameValuePair("title", title)); params.add(new BasicNameValuePair("endact", endAction)); if (timer.getId() > 0) { params.add(new BasicNameValuePair("id", String.valueOf(timer.getId()))); } String query = URLEncodedUtils.format(params, "utf-8"); String request = url + query; RecordingServiceGet rsGet = new RecordingServiceGet(request); Thread executionThread = new Thread(rsGet); executionThread.start(); return true; default: break; } return false; }