List of usage examples for android.os Bundle getLong
public long getLong(String key)
From source file:com.android.calendar.SearchActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); dynamicTheme.onCreate(this); // This needs to be created before setContentView mController = CalendarController.getInstance(this); mHandler = new Handler(); mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); setContentView(R.layout.search);/*from w w w .j a v a 2s . c o m*/ setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); mContentResolver = getContentResolver(); if (mIsMultipane) { if (getSupportActionBar() != null) { getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); } } else { if (getSupportActionBar() != null) { getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME); } } // Must be the first to register because this activity can modify the // list of event handlers in it's handle method. This affects who the // rest of the handlers the controller dispatches to are. mController.registerEventHandler(HANDLER_KEY, this); mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */); long millis = 0; if (icicle != null) { // Returns 0 if key not found millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME); if (DEBUG) { Log.v(TAG, "Restore value from icicle: " + millis); } } if (millis == 0) { // Didn't find a time in the bundle, look in intent or current time millis = Utils.timeFromIntentInMillis(getIntent()); } Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query; if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) { query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY); } else { query = intent.getStringExtra(SearchManager.QUERY); } if ("TARDIS".equalsIgnoreCase(query)) { Utils.tardis(); } initFragments(millis, query); } }
From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java
private void onRestore(Bundle savedInstanceState) { mAction = savedInstanceState.getString(KEY_ACTION); mGalleryInfo = savedInstanceState.getParcelable(KEY_GALLERY_INFO); mGid = savedInstanceState.getLong(KEY_GID); mToken = savedInstanceState.getString(KEY_TOKEN); mGalleryDetail = savedInstanceState.getParcelable(KEY_GALLERY_DETAIL); mRequestId = savedInstanceState.getInt(KEY_REQUEST_ID); }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
/** * This dialog applies to downloading directories only. * /* ww w . j a va2s . com*/ * @param extras * @return */ private Dialog buildDownloadDialog(final Bundle extras) { final String resourcePath = extras.getString(MetaService.EXTRA_RESOURCE_PATH); final long size = extras.getLong(MetaService.EXTRA_SIZE); final String sizeText = FileUtilities.getHumanReadableSize(size); final long free = StorageActivity.getAvailableExternalStorageSize(); if (free < size) { return buildInsufficientSpaceDialog(size, free); } final StringBuilder msgBuilder = new StringBuilder(32); msgBuilder.append(String.format(getString(R.string.dialog_downloading_dir_is_x_large), sizeText)); int network = NetworkUtil.getAvailableNetworkType(this); if (network == -1) { return buildNoNetworkDialog(); } else if (network == ConnectivityManager.TYPE_MOBILE) { msgBuilder.append(" "); msgBuilder.append(getString(R.string.dialog_downloading_dir_on_mobile)); } msgBuilder.append(" "); msgBuilder.append(getString(R.string.dialog_downloading_dir_are_you_sure)); final OnClickListener onClick = new OnClickListener() { private void download() { UpDownServiceHelper.download(FilesActivity.this, resourcePath); } public void onClick(DialogInterface dialog, int which) { switch (which) { case Dialog.BUTTON_POSITIVE: download(); break; case Dialog.BUTTON_NEGATIVE: // Will dismiss below. break; default: Log.e(TAG, "no such button"); break; } removeDialog(DIALOG_DOWNLOAD_ID); } }; final AlertDialog dialog = new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_info) .setTitle(R.string.dialog_downloading_dir_title).setMessage(msgBuilder.toString()) .setPositiveButton(R.string.yes, onClick).setNegativeButton(R.string.no, onClick).create(); return dialog; }
From source file:com.github.jvanhie.discogsscrobbler.ReleaseListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(this, R.xml.pref_discogs, false); setContentView(R.layout.activity_release_list); mReleaseProgressBar = (ProgressBar) findViewById(R.id.release_list_progressBar); mRefreshProgressBar = (ProgressBar) findViewById(R.id.release_list_refresh); mReleaseList = ((ReleaseListFragment) getSupportFragmentManager().findFragmentById(R.id.release_list)); if (mReleaseProgressBar != null && mLoaded) mReleaseProgressBar.setVisibility(View.INVISIBLE); if (mRefreshProgressBar != null && mRefresh) mRefreshProgressBar.setVisibility(View.VISIBLE); //check if we're in tablet mode -> two or tripane layout (hide details fields first, for a nice collection view) if (findViewById(R.id.release_pager_container) != null) { mPanes = 2;//from w ww . ja v a 2s . c o m findViewById(R.id.release_pager_container).setVisibility(View.GONE); } else if (findViewById(R.id.release_tracklist_container) != null) { mPanes = 3; findViewById(R.id.release_detail_container).setVisibility(View.GONE); findViewById(R.id.release_tracklist_container).setVisibility(View.GONE); } // Restore the previously serialized activated release if (savedInstanceState != null && savedInstanceState.containsKey(STATE_RELEASE_SELECTED)) { if (savedInstanceState.getInt(STATE_PANES) != mPanes) { //if the panelayout has changed, forcibly reload the fragments onItemSelected(savedInstanceState.getLong(STATE_RELEASE_SELECTED)); } } if (mDiscogs == null) mDiscogs = Discogs.getInstance(this); //create navigation drawer setDrawer(R.id.list_drawer_layout, R.id.list_drawer, getTitle().toString(), getTitle().toString(), true); }
From source file:com.ichi2.anki.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { Timber.d("onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.note_editor); Intent intent = getIntent();// w w w . ja v a 2s . c o m if (savedInstanceState != null) { mCaller = savedInstanceState.getInt("caller"); mAddNote = savedInstanceState.getBoolean("addFact"); mCurrentDid = savedInstanceState.getLong("did"); mSelectedTags = new ArrayList<>(Arrays.asList(savedInstanceState.getStringArray("tags"))); mSavedFields = savedInstanceState.getBundle("editFields"); } else { mCaller = intent.getIntExtra(EXTRA_CALLER, CALLER_NOCALLER); if (mCaller == CALLER_NOCALLER) { String action = intent.getAction(); if (action != null && (ACTION_CREATE_FLASHCARD.equals(action) || ACTION_CREATE_FLASHCARD_SEND.equals(action))) { mCaller = CALLER_CARDEDITOR_INTENT_ADD; } } } startLoadingCollection(); }
From source file:ca.uwaterloo.magic.goodhikes.MapsActivity.java
/** * onCreate() is called only once for Activity, whereas onStart() - each time * appActivity is hidden from screen (user uses other apps), and then App is activated again. * <p/>/*w w w.ja va2 s . c o m*/ * Using startService() overrides the default service lifetime that is managed by * bindService(Intent, ServiceConnection, int): it requires the service to remain running * until stopService(Intent) is called, regardless of whether any clients are connected to it. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); database = RoutesDatabaseManager.getInstance(this); userManager = new UserManager(getApplicationContext()); milestonePointMarkers = new ArrayList<Marker>(); markerImageMap = new HashMap<String, Bitmap>(); //Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); //Create and attach listeners to buttons mSettingsButton = (ImageButton) findViewById(R.id.settings_button); mShareButton = (ImageButton) findViewById(R.id.share_button); mStatisticsButton = (ImageButton) findViewById(R.id.statistics_button); mHistoryButton = (ImageButton) findViewById(R.id.history_button); mGPSTrackingButton = (ImageButton) findViewById(R.id.gps_tracking_control_button); mMilestoneButton = (ImageButton) findViewById(R.id.milestone_button); attachUICallbacks(); if (savedInstanceState != null) { long routeId = savedInstanceState.getLong(RouteEntry._ID); selectedRoute = database.getRoute(routeId); followingExistingRoute = savedInstanceState.getBoolean("followingExistingRoute"); } }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ???// w w w.j a va 2 s .c om * * @param savedInstanceState Bundle */ private void loadActivitySavedData(Bundle savedInstanceState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { String fieldName = f.getName(); @SuppressWarnings("rawtypes") Class cls = f.getType(); if (cls == int.class || cls == Integer.class) { f.setInt(this, savedInstanceState.getInt(fieldName)); } else if (String.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getString(fieldName)); } else if (Serializable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getSerializable(fieldName)); } else if (cls == long.class || cls == Long.class) { f.setLong(this, savedInstanceState.getLong(fieldName)); } else if (cls == short.class || cls == Short.class) { f.setShort(this, savedInstanceState.getShort(fieldName)); } else if (cls == boolean.class || cls == Boolean.class) { f.setBoolean(this, savedInstanceState.getBoolean(fieldName)); } else if (cls == byte.class || cls == Byte.class) { f.setByte(this, savedInstanceState.getByte(fieldName)); } else if (cls == char.class || cls == Character.class) { f.setChar(this, savedInstanceState.getChar(fieldName)); } else if (CharSequence.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getCharSequence(fieldName)); } else if (cls == float.class || cls == Float.class) { f.setFloat(this, savedInstanceState.getFloat(fieldName)); } else if (cls == double.class || cls == Double.class) { f.setDouble(this, savedInstanceState.getDouble(fieldName)); } else if (String[].class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getStringArray(fieldName)); } else if (Parcelable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getParcelable(fieldName)); } else if (Bundle.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getBundle(fieldName)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } }
From source file:com.barkside.travellocblog.LocationUpdates.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutResourceId()); // Get handles to the UI view objects - for now there are none in this abstract class. // Parent class may define some common UI controls, and those can be accessed here. mActivityIndicator = getProgressBar(); // Create a new global location parameters object mLocationRequest = LocationRequest.create(); /*//from w w w.ja v a 2 s. c o m * Set the update interval */ mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); // Use high accuracy mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the interval ceiling to one minute mLocationRequest.setFastestInterval(FAST_INTERVAL_CEILING_IN_MILLISECONDS); // Note that location updates are off until the concrete class turns them on mUpdatesRequested = false; mExpirationTime = 0; if (savedInstanceState != null) { mExpirationTime = savedInstanceState.getLong("mExpirationTime"); } /* * Create a new location client, using the enclosing class to * handle callbacks. */ mLocationClient = new LocationClient(this, this, this); }
From source file:com.android.music.TrackBrowserFragment.java
/** Called when the activity is first created. */ @Override/*from ww w. j a v a2 s . co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.media_picker_activity, null); Intent intent = getActivity().getIntent(); /*if (intent != null) { if (intent.getBooleanExtra("withtabs", false)) { getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE); } }*/ getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); if (savedInstanceState != null) { mSelectedId = savedInstanceState.getLong("selectedtrack"); mAlbumId = savedInstanceState.getString("album"); mArtistId = savedInstanceState.getString("artist"); mPlaylist = savedInstanceState.getString("playlist"); mGenre = savedInstanceState.getString("genre"); mEditMode = savedInstanceState.getBoolean("editmode", false); } else { mAlbumId = intent.getStringExtra("album"); // If we have an album, show everything on the album, not just stuff // by a particular artist. mArtistId = intent.getStringExtra("artist"); mPlaylist = intent.getStringExtra("playlist"); mGenre = intent.getStringExtra("genre"); mEditMode = intent.getAction().equals(Intent.ACTION_EDIT); } mCursorCols = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ARTIST_ID, MediaStore.Audio.Media.DURATION }; mPlaylistMemberCols = new String[] { MediaStore.Audio.Playlists.Members._ID, MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ARTIST_ID, MediaStore.Audio.Media.DURATION, MediaStore.Audio.Playlists.Members.PLAY_ORDER, MediaStore.Audio.Playlists.Members.AUDIO_ID, MediaStore.Audio.Media.IS_MUSIC }; //mUseLastListPos = MusicUtils.updateButtonBar(getActivity(), R.id.songtab); mTrackList = (ListView) view.findViewById(android.R.id.list); mTrackList.setOnCreateContextMenuListener(this); mTrackList.setCacheColorHint(0); if (mEditMode) { ((TouchInterceptor) mTrackList).setDropListener(mDropListener); ((TouchInterceptor) mTrackList).setRemoveListener(mRemoveListener); mTrackList.setDivider(null); mTrackList.setSelector(R.drawable.list_selector_background); } else { mTrackList.setTextFilterEnabled(true); } mAdapter = (TrackListAdapter) getActivity().getLastNonConfigurationInstance(); if (mAdapter != null) { mAdapter.setActivity(this); mTrackList.setAdapter(mAdapter); } mToken = MusicUtils.bindToService(getActivity(), this); // don't set the album art until after the view has been layed out mTrackList.post(new Runnable() { public void run() { setAlbumArtBackground(); } }); // mTrackList.dispatchKeyEvent(); mTrackList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (mTrackCursor.getCount() == 0) { return; } // When selecting a track from the queue, just jump there instead of // reloading the queue. This is both faster, and prevents accidentally // dropping out of party shuffle. if (mTrackCursor instanceof NowPlayingCursor) { if (MusicUtils.sService != null) { try { MusicUtils.sService.setQueuePosition(position); return; } catch (RemoteException ex) { } } } MusicUtils.playAll(getActivity(), mTrackCursor, position); } }); return view; }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTweetingsApplication().getServiceInterface(); mResolver = getContentResolver();//from w w w . ja v a 2 s .co m super.onCreate(savedInstanceState); setContentView(R.layout.compose); mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1; mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null; mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1; mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null; mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null; mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null; mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false; mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false; mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null; final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null; final String account_username = getAccountUsername(this, account_id); int text_selection_start = -1; mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false; if (mInReplyToStatusId > 0) { if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null && (mentions == null || mentions.length < 1)) { mText = bundle.getString(INTENT_KEY_TEXT); } else if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); text_selection_start = mText.indexOf(' ') + 1; } mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false; final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String name = display_name ? mInReplyToName : mInReplyToScreenName; if (name != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } TextView replyText = (TextView) findViewById(R.id.reply_text); if (!isNullOrEmpty(mInReplyToText)) { replyText.setVisibility(View.VISIBLE); replyText.setText(mInReplyToText); } else { replyText.setVisibility(View.GONE); } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); } if (mAccountIds == null || mAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ','); final long[] activated_ids = getActivatedAccountIds(this); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids); mAccountIds = intersection.length > 0 ? intersection : activated_ids; } final String action = getIntent().getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { setTitle(R.string.share); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (mText == null) { final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT); final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT); mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text)); } else { mText = bundle.getString(INTENT_KEY_TEXT); } if (mImageUri == null) { final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM); final String content_type = getIntent().getType(); if (extra_stream != null && content_type != null && content_type.startsWith("image/")) { final String real_path = getImagePathFromUri(this, extra_stream); final File file = real_path != null ? new File(real_path) : null; if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsImageAttached = true; mIsPhotoAttached = false; } else { mImageUri = null; mIsImageAttached = false; } } } } } else if (bundle != null) { if (bundle.getString(INTENT_KEY_TEXT) != null) { mText = bundle.getString(INTENT_KEY_TEXT); } } } final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme()) ? new File(mImageUri.getPath()) : null; final boolean image_file_valid = image_file != null && image_file.exists(); mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE); if (image_file_valid) { reloadAttachedImageThumbnail(image_file); } mImageThumbnailPreview.setOnClickListener(this); mImageThumbnailPreview.setOnLongClickListener(this); mMenuBar.setOnMenuItemClickListener(this); mMenuBar.inflate(R.menu.menu_compose); mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance()); mEditText.setImeOptions(EditorInfo.IME_ACTION_GO); mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); if (mText != null) { mEditText.setText(mText); if (mIsQuote) { mEditText.setSelection(0); } else if (text_selection_start != -1 && text_selection_start < mEditText.length() && mEditText.length() > 0) { mEditText.setSelection(text_selection_start, mEditText.length() - 1); } else if (mEditText.length() > 0) { mEditText.setSelection(mEditText.length()); } } invalidateSupportOptionsMenu(); setMenu(); if (mColorIndicator != null) { mColorIndicator.setOrientation(ColorView.VERTICAL); mColorIndicator.setColor(getAccountColors(this, mAccountIds)); } mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED) : false; mIsPossiblySensitive = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE) : false; }