List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:de.fahrgemeinschaft.RideDetailsFragment.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putInt(SELECTED, selected); super.onSaveInstanceState(outState); }
From source file:com.makerfaireorlando.makerfaireorlando.MainActivity.java
public void onEventSelected(int p) { EventDetailFragment newFragment = new EventDetailFragment(); Bundle args = new Bundle(); args.putInt("Position", p); newFragment.setArguments(args);// w w w . j ava2 s.co m FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.content_frame, newFragment).setCustomAnimations(android.R.anim.slide_in_left, 0, 0, android.R.anim.slide_out_right); transaction.addToBackStack(null); mDrawerToggle.setDrawerIndicatorEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); transaction.commit(); }
From source file:com.example.alvarpao.popularmovies.MovieDetailFragment.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { //Save movie details to be restored after rotation if (mMovie != null) savedInstanceState.putParcelable(MOVIE, mMovie); // Save current scroll position for the recycler view savedInstanceState.putInt(SCROLL_POSITION, ((LinearLayoutManager) mMovieDetailsRecyclerView.getLayoutManager()) .findFirstVisibleItemPosition()); }
From source file:com.amaze.filemanager.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); b.putInt("id", startId); epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String file = intent.getStringExtra("zip"); eentries = intent.getBooleanExtra("entries1", false); if (eentries) { entries = intent.getStringArrayListExtra("entries"); }//from w w w. jav a2 s . c o m b.putString("file", file); DataPackage intent1 = new DataPackage(); intent1.setName(file); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(cd); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.extracting)) .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed); hash.put(startId, true); new Doback().execute(b); return START_STICKY; }
From source file:com.sababado.network.AsyncServiceCallTask.java
@Override protected Bundle doInBackground(Void... args) { mRunning = true;/*from w ww .ja v a2 s .c o m*/ log(LOG_TYPE_DEBUG, "****in AsyncServiceCallTask do in Background"); int attempts = 0; if (!UtilNetwork.isNetworkAvailable(mContext)) { Bundle responseBundle = new Bundle(); responseBundle.putString(EXTRA_ERR_MSG, "Sorry, there is limited or no connectivity. Please try again later."); responseBundle.putInt(EXTRA_ERR_CODE, ERR_CODE_NO_NETWORK); return responseBundle; } //get names and values String[] paramNames = mService.getAllParamNames(); String[] paramValues = mService.getAllParamValues(); //build parameter list String paramString = ""; if (paramNames != null && paramNames.length > 0) { try { //this assumes there is a 1 to 1 number of names and values List<NameValuePair> nvPairs = new LinkedList<NameValuePair>(); for (int i = 0; i < paramNames.length; i++) { nvPairs.add(new BasicNameValuePair(paramNames[i], paramValues[i])); } paramString = URLEncodedUtils.format(nvPairs, "utf-8"); } catch (ArrayIndexOutOfBoundsException e) { String message = "Failed paring param names and values (Index out of bounds). Make sure the there are the same number of param names and values."; log(LOG_TYPE_ERROR, message); throw new ArrayIndexOutOfBoundsException(message); } } String url = mService.getUrl(); //format the url string if (paramString.length() > 0) { //format url to have parameters only if there are parameters to add. if (!url.endsWith("?")) url += "?"; url += paramString; } log(LOG_TYPE_DEBUG, "Url: " + url); HttpResponse response = null; //while under the maximum number of attempts... while (attempts < MAX_ATTEMPTS) { try { log(LOG_TYPE_DEBUG, (attempts + 1) + "/" + MAX_ATTEMPTS + ": Creating Http Client"); //create the HttpClient HttpClient client = new DefaultHttpClient(); //set the request switch (mService.getCallType()) { case Service.CALL_TYPE_GET: log(LOG_TYPE_DEBUG, "Making GET Call"); HttpGet getRequest = new HttpGet(url); response = client.execute(getRequest); break; case Service.CALL_TYPE_POST: log(LOG_TYPE_DEBUG, "Making POST Call"); HttpPost postRequest = new HttpPost(url); response = client.execute(postRequest); break; case Service.CALL_TYPE_PUT: log(LOG_TYPE_DEBUG, "Making PUT Call"); HttpPut putRequest = new HttpPut(url); response = client.execute(putRequest); break; case Service.CALL_TYPE_DELETE: log(LOG_TYPE_DEBUG, "Making DELETE Call"); HttpDelete deleteRequest = new HttpDelete(url); response = client.execute(deleteRequest); break; default: throw new RuntimeException( "Invalid Call type, please see Service.CALL_TYPE_* for possible types."); } } catch (IOException e) { attempts++; publishProgress("IOException: Retrying, attempt " + (attempts + 1), e.getMessage()); } if (response != null) break; } //check if exceeded max number of attempts if (attempts == MAX_ATTEMPTS) { //max number of attempts exceeded, error Bundle responseBundle = new Bundle(); //responseBundle.putString(EXTRA_ERR_MSG, "Failed "+MAX_ATTEMPTS+" attempts, please retry later."); responseBundle.putString(EXTRA_ERR_MSG, "Could not connect to the server, please try again later"); responseBundle.putInt(EXTRA_ERR_CODE, ERR_CODE_MAX_ATTEMPTS_REACHED); return responseBundle; } return parseResponse(response); }
From source file:com.nextgis.metroaccess.MetaDownloader.java
@Override protected Void doInBackground(String... urls) { if (IsNetworkAvailible(moContext)) { try {// ww w .j a v a 2 s . c o m String sURL = urls[0]; moHTTPGet = new HttpGet(sURL); Log.d(TAG, "HTTPGet URL " + sURL); 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(moHTTPGet); if (response == null) return null; HttpEntity entity = response.getEntity(); if (moEventReceiver != null) { if (entity != null) { Bundle bundle = new Bundle(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { bundle.putBoolean(BUNDLE_ERRORMARK_KEY, false); msContent = EntityUtils.toString(entity, HTTP.UTF_8); bundle.putString(BUNDLE_PAYLOAD_KEY, msContent); bundle.putInt(BUNDLE_EVENTSRC_KEY, 1); } else { bundle.putBoolean(BUNDLE_ERRORMARK_KEY, true); bundle.putString(BUNDLE_MSG_KEY, moContext.getString(R.string.sNetworkGetErr)); bundle.putInt(BUNDLE_EVENTSRC_KEY, 1); } Message oMsg = new Message(); oMsg.setData(bundle); moEventReceiver.sendMessage(oMsg); } else { msError = moContext.getString(R.string.sNetworkUnreachErr); } } } catch (ClientProtocolException e) { msError = e.getMessage(); //cancel(true); } catch (IOException e) { msError = e.getMessage(); //cancel(true); } } else { if (moEventReceiver != null) { Bundle bundle = new Bundle(); bundle.putBoolean(BUNDLE_ERRORMARK_KEY, true); bundle.putString(BUNDLE_MSG_KEY, moContext.getString(R.string.sNetworkUnreachErr)); bundle.putInt(BUNDLE_EVENTSRC_KEY, 1); Message oMsg = new Message(); oMsg.setData(bundle); moEventReceiver.sendMessage(oMsg); } } return null; }
From source file:com.dwdesign.tweetings.fragment.AccountsFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { if (mSelectedUserId <= 0) return false; switch (item.getItemId()) { case MENU_VIEW_PROFILE: { openUserProfile(getActivity(), mSelectedUserId, mSelectedUserId, null); break;//w w w . jav a 2s .c om } case MENU_SET_COLOR: { final Intent intent = new Intent(INTENT_ACTION_SET_COLOR); final Bundle bundle = new Bundle(); bundle.putInt(Accounts.USER_COLOR, mSelectedColor); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_SET_COLOR); break; } case MENU_SET_AS_DEFAULT: { setDefaultAccount(mSelectedUserId); break; } case MENU_DELETE: { mResolver.delete(Accounts.CONTENT_URI, Accounts.USER_ID + " = " + mSelectedUserId, null); // Also delete tweets related to the account we previously // deleted. mResolver.delete(Statuses.CONTENT_URI, Statuses.ACCOUNT_ID + " = " + mSelectedUserId, null); mResolver.delete(Mentions.CONTENT_URI, Mentions.ACCOUNT_ID + " = " + mSelectedUserId, null); mResolver.delete(DirectMessages.Inbox.CONTENT_URI, DirectMessages.ACCOUNT_ID + " = " + mSelectedUserId, null); mResolver.delete(DirectMessages.Outbox.CONTENT_URI, DirectMessages.ACCOUNT_ID + " = " + mSelectedUserId, null); if (getActivatedAccountIds(getActivity()).length > 0) { getLoaderManager().restartLoader(0, null, AccountsFragment.this); } else { getActivity().finish(); } break; } } return super.onContextItemSelected(item); }
From source file:com.yairkukielka.feedhungry.EntryListFragment.java
private void refreshItems() { if (streamId == null || accessToken == null || isMix == null || getActivity() == null) { Log.e(TAG, "No stream to load in EntryListFragment.refreshItems or activity is null"); return;// w w w. ja va 2 s . c o m } mEntries.clear(); mHasData = false; mAdapter = new ListViewEntryArrayAdapter(getActivity(), 0, mEntries, MyVolley.getImageLoader()); ((AdapterView) mLvPicasa).setAdapter(mAdapter); mLvPicasa.setOnScrollListener(new EndlessScrollListener()); if (!mHasData) { addLoadingFragment(); } mLvPicasa.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(EntryListFragment.this.getActivity(), FeedEntryActivity_.class); ListEntry listEntry = mEntries.get(position); mAdapter.markEntry(MARK_ACTION.READ, mEntries.get(position)); Bundle b = new Bundle(); b.putString(ACCESS_TOKEN, accessToken); b.putString(ENTRY_ID, listEntry.getId()); b.putString(STREAM_ID, streamId); b.putInt(ENTRY_POSITION_IN_STREAM, position); intent.putExtras(b); startActivity(intent); EntryListFragment.this.getActivity().overridePendingTransition(R.anim.open_next, R.anim.close_main); } }); if (!mHasData) { loadPage(false); } }
From source file:com.irccloud.android.activity.PastebinsActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("page", page); adapter.saveInstanceState(outState); }
From source file:com.nextgis.maplibui.dialog.CreateFromQMSLayerDialog.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putInt(KEY_ID, mGroupLayer.getId()); super.onSaveInstanceState(outState); }