List of usage examples for android.os Bundle getLong
public long getLong(String key)
From source file:com.ultramegasoft.flavordex2.fragment.AddEntryFragment.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);/* www .j a va2s. c o m*/ final AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return; } final Bundle args = getArguments(); if (args != null) { mCatId = args.getLong(ARG_CAT_ID); mCatName = args.getString(ARG_CAT_NAME); } final ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { final String name = FlavordexApp.getRealCatName(activity, mCatName); final String title = getString(R.string.title_add_cat_entry, name); actionBar.setTitle(title); } }
From source file:com.ota.updates.receivers.AppReceiver.java
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras(); long mRomDownloadID = Preferences.getDownloadID(context); if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) { long id = extras.getLong(DownloadManager.EXTRA_DOWNLOAD_ID); boolean isAddonDownload = false; int keyForAddonDownload = 0; Set<Integer> set = OtaUpdates.getAddonDownloadKeySet(); Iterator<Integer> iterator = set.iterator(); while (iterator.hasNext() && isAddonDownload != true) { int nextValue = iterator.next(); if (id == OtaUpdates.getAddonDownload(nextValue)) { isAddonDownload = true;/*from ww w.j a v a 2 s .c om*/ keyForAddonDownload = nextValue; if (DEBUGGING) { Log.d(TAG, "Checking ID " + nextValue); } } } if (isAddonDownload) { DownloadManager downloadManager = (DownloadManager) context .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(id); Cursor cursor = downloadManager.query(query); // it shouldn't be empty, but just in case if (!cursor.moveToFirst()) { if (DEBUGGING) Log.e(TAG, "Addon Download Empty row"); return; } int statusIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL != cursor.getInt(statusIndex)) { if (DEBUGGING) Log.w(TAG, "Download Failed"); Log.d(TAG, "Removing Addon download with id " + keyForAddonDownload); OtaUpdates.removeAddonDownload(keyForAddonDownload); AddonActivity.AddonsArrayAdapter.updateProgress(keyForAddonDownload, 0, true); AddonActivity.AddonsArrayAdapter.updateButtons(keyForAddonDownload, false); return; } else { if (DEBUGGING) Log.v(TAG, "Download Succeeded"); Log.d(TAG, "Removing Addon download with id " + keyForAddonDownload); OtaUpdates.removeAddonDownload(keyForAddonDownload); AddonActivity.AddonsArrayAdapter.updateButtons(keyForAddonDownload, true); return; } } else { if (DEBUGGING) Log.v(TAG, "Receiving " + mRomDownloadID); if (id != mRomDownloadID) { if (DEBUGGING) Log.v(TAG, "Ignoring unrelated non-ROM download " + id); return; } DownloadManager downloadManager = (DownloadManager) context .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(id); Cursor cursor = downloadManager.query(query); // it shouldn't be empty, but just in case if (!cursor.moveToFirst()) { if (DEBUGGING) Log.e(TAG, "Rom download Empty row"); return; } int statusIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL != cursor.getInt(statusIndex)) { if (DEBUGGING) Log.w(TAG, "Download Failed"); Preferences.setDownloadFinished(context, false); if (Utils.isLollipop()) { AvailableActivity.setupMenuToolbar(context); // Reset options menu } else { AvailableActivity.invalidateMenu(); } return; } else { if (DEBUGGING) Log.v(TAG, "Download Succeeded"); Preferences.setDownloadFinished(context, true); AvailableActivity.setupProgress(context); if (Utils.isLollipop()) { AvailableActivity.setupMenuToolbar(context); // Reset options menu } else { AvailableActivity.invalidateMenu(); } return; } } } if (action.equals(DownloadManager.ACTION_NOTIFICATION_CLICKED)) { long[] ids = extras.getLongArray(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS); for (long id : ids) { if (id != mRomDownloadID) { if (DEBUGGING) Log.v(TAG, "mDownloadID is " + mRomDownloadID + " and ID is " + id); return; } else { Intent i = new Intent(context, AvailableActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } } } if (action.equals(MANIFEST_CHECK_BACKGROUND)) { if (DEBUGGING) Log.d(TAG, "Receiving background check confirmation"); boolean updateAvailable = RomUpdate.getUpdateAvailability(context); String filename = RomUpdate.getFilename(context); if (updateAvailable) { Utils.setupNotification(context, filename); Utils.scheduleNotification(context, !Preferences.getBackgroundService(context)); } } if (action.equals(START_UPDATE_CHECK)) { if (DEBUGGING) Log.d(TAG, "Update check started"); new LoadUpdateManifest(context, false).execute(); } if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { if (DEBUGGING) { Log.d(TAG, "Boot received"); } boolean backgroundCheck = Preferences.getBackgroundService(context); if (backgroundCheck) { if (DEBUGGING) Log.d(TAG, "Starting background check alarm"); Utils.scheduleNotification(context, !Preferences.getBackgroundService(context)); } } if (action.equals(IGNORE_RELEASE)) { if (DEBUGGING) { Log.d(TAG, "Ignore release"); } Preferences.setIgnoredRelease(context, Integer.toString(RomUpdate.getVersionNumber(context))); final NotificationManager mNotifyManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Builder mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle(context.getString(R.string.main_release_ignored)) .setSmallIcon(R.drawable.ic_notif) .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(), 0)); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); Handler h = new Handler(); long delayInMilliseconds = 1500; h.postDelayed(new Runnable() { public void run() { mNotifyManager.cancel(NOTIFICATION_ID); } }, delayInMilliseconds); } }
From source file:com.glanznig.beepme.data.DataExporter.java
private File writeHistoryCSV(File tempDir) { BeeperApp app = (BeeperApp) ctx.getApplicationContext(); List<Bundle> statList = Statistics.getStats(ctx, app.getTimerProfile()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); File csvFile = new File(tempDir, "history.csv"); try {//from w w w. ja va 2s . c om CSVWriter writer = new CSVWriter(new FileWriter(csvFile), ';'); writer.writeNext("Date#Accepted#Declined#Elapsed".split("#")); Iterator<Bundle> i = statList.iterator(); while (i.hasNext()) { Bundle item = i.next(); ArrayList<String> list = new ArrayList<String>(); list.add(dateFormat.format(new Date(item.getLong("timestamp")))); if (item.containsKey("acceptedSamples")) { list.add(String.valueOf(item.getInt("acceptedSamples", 0))); } else { list.add("0"); } if (item.containsKey("declinedSamples")) { list.add(String.valueOf(item.getInt("declinedSamples", 0))); } else { list.add("0"); } if (item.containsKey("uptimeDuration")) { long uptimeDur = item.getLong("uptimeDuration") / 1000; String timeActive = String.format("%02d:%02d:%02d", uptimeDur / 3600, (uptimeDur % 3600) / 60, (uptimeDur % 60)); list.add(timeActive); } else { list.add("00:00:00"); } String[] listArray = new String[list.size()]; listArray = list.toArray(listArray); writer.writeNext(listArray); } writer.close(); } catch (IOException ioe) { Log.e(TAG, "error writing history csv file."); return null; } return csvFile; }
From source file:com.github.kanata3249.ffxieq.android.FoodSelectorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Bundle param; super.onCreate(savedInstanceState); if (savedInstanceState != null) { param = savedInstanceState;// ww w. j a v a2 s . c o m } else { param = getIntent().getExtras(); } mCurrent = param.getLong("Current"); mFilterID = param.getLong("Filter"); mFilterByType = param.getString("FilterByType"); setContentView(R.layout.foodselector); }
From source file:com.javielinux.tweettopics2.SearchActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); themeManager = new ThemeManager(this); themeManager.setDialogTheme();//from www .jav a 2 s .com themeManager.setColors(); String defaultSearch = ""; Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(DataFramework.KEY_ID)) { search_entity = new EntitySearch(extras.getLong(DataFramework.KEY_ID)); } if (extras.containsKey(KEY_SEARCH)) { defaultSearch = extras.getString(KEY_SEARCH); } } overridePendingTransition(R.anim.pull_in_to_up, R.anim.hold); if (search_entity == null) search_entity = new EntitySearch(); setContentView(R.layout.search_activity); findViewById(R.id.buttons_foot).setBackgroundColor(themeManager.getColor("color_bottom_bar")); fragmentAdapter = new SearchFragmentAdapter(this, getSupportFragmentManager(), search_entity, defaultSearch); pager = (ViewPager) findViewById(R.id.search_pager); pager.setAdapter(fragmentAdapter); searchRoot = (RelativeLayout) findViewById(R.id.search_root); searchBar = (RelativeLayout) findViewById(R.id.search_bar_background); indicator = (TabPageIndicator) findViewById(R.id.search_indicator); indicator.setViewPager(pager); findViewById(R.id.bt_save).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doSave(); } }); findViewById(R.id.bt_save_and_view).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doSaveAndView(); } }); refreshTheme(); }
From source file:com.andryr.musicplayer.fragments.PlaylistFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); setHasOptionsMenu(true);/*from www . j a va 2s .c om*/ if (args != null) { if (args.getBoolean(PARAM_PLAYLIST_FAVORITES)) { mFavorites = true; } else { long id = args.getLong(PARAM_PLAYLIST_ID); String name = args.getString(PARAM_PLAYLIST_NAME); mPlaylist = new Playlist(id, name); } } }
From source file:com.xandy.calendar.EventInfoActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get the info needed for the fragment Intent intent = getIntent();/*ww w.ja v a2 s. c om*/ int attendeeResponse = 0; mEventId = -1; boolean isDialog = false; ArrayList<ReminderEntry> reminders = null; if (icicle != null) { mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID); mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS); mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS); attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE); isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG); reminders = Utils.readRemindersFromBundle(icicle); } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0); mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0); attendeeResponse = intent.getIntExtra(ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE); Uri data = intent.getData(); if (data != null) { try { List<String> pathSegments = data.getPathSegments(); int size = pathSegments.size(); if (size > 2 && "EventTime".equals(pathSegments.get(2))) { // Support non-standard VIEW intent format: //dat = content://com.android.calendar/events/[id]/EventTime/[start]/[end] mEventId = Long.parseLong(pathSegments.get(1)); if (size > 4) { mStartMillis = Long.parseLong(pathSegments.get(3)); mEndMillis = Long.parseLong(pathSegments.get(4)); } } else { mEventId = Long.parseLong(data.getLastPathSegment()); } } catch (NumberFormatException e) { if (mEventId == -1) { // do nothing here , deal with it later } else if (mStartMillis == 0 || mEndMillis == 0) { // Parsing failed on the start or end time , make sure the times were not // pulled from the intent's extras and reset them. mStartMillis = 0; mEndMillis = 0; } } } } if (mEventId == -1) { Log.w(TAG, "No event id"); Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show(); finish(); } // If we do not support showing full screen event info in this configuration, // close the activity and show the event in AllInOne. Resources res = getResources(); if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen) && !res.getBoolean(R.bool.show_event_info_full_screen)) { CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis, attendeeResponse); finish(); return; } setContentView(R.layout.simple_frame_layout); // Get the fragment if exists mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); // Remove the application title ActionBar bar = getActionBar(); if (bar != null) { bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME); } // Create a new fragment if none exists if (mInfoFragment == null) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse, isDialog, (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE), reminders); ft.replace(R.id.main_frame, mInfoFragment); ft.commit(); } }
From source file:com.android.calendar.EventInfoActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get the info needed for the fragment Intent intent = getIntent();/* w ww. ja v a 2 s. co m*/ int attendeeResponse = 0; mEventId = -1; boolean isDialog = false; ArrayList<ReminderEntry> reminders = null; if (icicle != null) { mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID); mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS); mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS); attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE); isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG); reminders = Utils.readRemindersFromBundle(icicle); } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0); mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0); attendeeResponse = intent.getIntExtra("attendeeStatus", Attendees.ATTENDEE_STATUS_NONE); Uri data = intent.getData(); if (data != null) { try { List<String> pathSegments = data.getPathSegments(); int size = pathSegments.size(); if (size > 2 && "EventTime".equals(pathSegments.get(2))) { // Support non-standard VIEW intent format: // dat = // content://com.android.calendar/events/[id]/EventTime/[start]/[end] mEventId = Long.parseLong(pathSegments.get(1)); if (size > 4) { mStartMillis = Long.parseLong(pathSegments.get(3)); mEndMillis = Long.parseLong(pathSegments.get(4)); } } else { mEventId = Long.parseLong(data.getLastPathSegment()); } } catch (NumberFormatException e) { if (mEventId == -1) { // do nothing here , deal with it later } else if (mStartMillis == 0 || mEndMillis == 0) { // Parsing failed on the start or end time , make sure // the times were not // pulled from the intent's extras and reset them. mStartMillis = 0; mEndMillis = 0; } } } } if (mEventId == -1) { Log.w(TAG, "No event id"); Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show(); finish(); } // If we do not support showing full screen event info in this // configuration, // close the activity and show the event in AllInOne. Resources res = getResources(); if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen) && !res.getBoolean(R.bool.show_event_info_full_screen)) { CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis, attendeeResponse); finish(); return; } setContentView(R.layout.simple_frame_layout); // Get the fragment if exists mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); // Remove the application title ActionBar bar = getActionBar(); if (bar != null) { bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP); } // Create a new fragment if none exists if (mInfoFragment == null) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse, isDialog, (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE), reminders); ft.replace(R.id.main_frame, mInfoFragment); ft.commit(); } }
From source file:de.elanev.studip.android.app.frontend.courses.CourseOverviewFragment.java
public Loader<Cursor> onCreateLoader(int id, Bundle data) { if (data == null) { throw new IllegalStateException("Bundle data must not be null!"); }/*from ww w. ja va2 s . com*/ String cid = data.getString(CoursesContract.Columns.Courses.COURSE_ID); long dbId = data.getLong(CoursesContract.Columns.Courses._ID); // Create loaders based on id switch (id) { case COURSE_LOADER: return new CursorLoader(mContext, CoursesContract.CONTENT_URI.buildUpon().appendPath(Long.toString(dbId)).build(), CourseItemQuery.projection, null, null, CoursesContract.DEFAULT_SORT_ORDER); case COURSE_EVENTS_LOADER: return new CursorLoader(mContext, CoursesContract.CONTENT_URI.buildUpon().appendPath("events").appendPath(cid).build(), CourseEventQuery.projection, EventsContract.Columns.EVENT_START + " >= strftime" + "('%s','now')", null, EventsContract.DEFAULT_SORT_ORDER + " LIMIT 1"); case COURSE_NEWS_LOADER: return new CursorLoader(mContext, NewsContract.CONTENT_URI.buildUpon().appendPath(cid).build(), CourseNewsQuery.projection, null, null, NewsContract.DEFAULT_SORT_ORDER + " LIMIT 1"); case COURSE_TEACHERS_LOADER: return new CursorLoader(mContext, UsersContract.CONTENT_URI.buildUpon().appendPath("course").appendPath(cid).build(), CourseUsersQuery.projection, CourseUsersQuery.selection, CourseUsersQuery.selectionArgs, CoursesContract.Qualified.CourseUsers.COURSES_USERS_TABLE_ID + " ASC"); } return null; }
From source file:can.yrt.onebusaway.ReportTripProblemFragment.java
@Override protected ReportLoader createLoader(Bundle args) { // Trip ID/* w w w . j a v a 2s .co m*/ String tripId = args.getString(TRIP_ID); ObaReportProblemWithTripRequest.Builder builder = new ObaReportProblemWithTripRequest.Builder(getActivity(), tripId); builder.setStopId(args.getString(STOP_ID)); builder.setVehicleId(args.getString(TRIP_VEHICLE_ID)); builder.setServiceDate(args.getLong(TRIP_SERVICE_DATE)); // Code String code = SPINNER_TO_CODE[mCodeView.getSelectedItemPosition()]; if (code != null) { builder.setCode(code); } // Comment CharSequence comment = mUserComment.getText(); if (!TextUtils.isEmpty(comment)) { builder.setUserComment(comment.toString()); } // Location / Location accuracy Location location = LocationHelp.getLocation2(getActivity()); if (location != null) { builder.setUserLocation(location.getLatitude(), location.getLongitude()); if (location.hasAccuracy()) { builder.setUserLocationAccuracy((int) location.getAccuracy()); } } // User on vehicle? builder.setUserOnVehicle(mUserOnVehicle.isChecked()); // User Vehicle Number CharSequence vehicleNum = mUserVehicle.getText(); if (!TextUtils.isEmpty(vehicleNum)) { builder.setUserVehicleNumber(vehicleNum.toString()); } return new ReportLoader(getActivity(), builder.build()); }