List of usage examples for android.content Intent getSerializableExtra
public Serializable getSerializableExtra(String name)
From source file:dat255.grupp06.bibbla.MainActivity.java
/** * {@inheritdoc}//from w w w . j av a2 s.co m * * This is called when a user is done with LoginOverlayActivity. Saves the * specified credentials and tells Backend to log in. * @param data should contain a Credentials object as an Extra, identified * by LoginManager.EXTRA_CREDENTIALS */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CANCELED) { profileFragment.setDontLogin(true); } switch (requestCode) { case RESULT_LOGIN_FORM: // Get credentials if (resultCode != RESULT_CANCELED) { Credentials cred = (Credentials) data.getSerializableExtra(EXTRA_CREDENTIALS); if (cred == null) { // Retry login form (recursive) showCredentialsDialog(loginDoneCallback); } else { this.saveCredentials(cred); backend.saveCredentials(cred); profileFragment.setDontGetCachedBooks(true); } } loginDoneCallback.handleMessage(new Message()); // The callback should not be handled more than once. loginDoneCallback = null; break; default: throw new IllegalArgumentException("onActivityResult was called " + "with an unknown request code"); } }
From source file:com.sparksoftsolutions.com.pdfcreator.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // crate a page description if (resultCode == ImagePicker.RESULT_CODE_ITEMS) { if (data != null && requestCode == LIBRARY_RESULT) { ArrayList<ImageItem> images = (ArrayList<ImageItem>) data .getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS); if (images.size() > 0) { CreatePDFBackgroundTask task = new CreatePDFBackgroundTask(images, this); task.execute();/* ww w .j av a 2s . c o m*/ } } } }
From source file:com.duy.pascal.ui.editor.BaseEditorActivity.java
private void loadFileFromIntent() { Intent intent = getIntent(); if (intent != null && intent.getSerializableExtra(CompileManager.EXTRA_FILE) != null) { File file = (File) intent.getSerializableExtra(CompileManager.EXTRA_FILE); //No need save last file because it is the first file addNewPageEditor(file);//from w w w . j av a 2 s. c om //Remove path intent.removeExtra(CompileManager.EXTRA_FILE); } }
From source file:org.acra.sender.SenderService.java
@Override protected void onHandleWork(@NonNull final Intent intent) { if (!intent.hasExtra(EXTRA_ACRA_CONFIG)) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "SenderService was started but no valid intent was delivered, will now quit"); return;// www . j a v a 2 s . com } final boolean onlySendSilentReports = intent.getBooleanExtra(EXTRA_ONLY_SEND_SILENT_REPORTS, false); final boolean approveReportsFirst = intent.getBooleanExtra(EXTRA_APPROVE_REPORTS_FIRST, false); final ACRAConfiguration config = (ACRAConfiguration) intent.getSerializableExtra(EXTRA_ACRA_CONFIG); final Collection<Class<? extends ReportSenderFactory>> senderFactoryClasses = config .reportSenderFactoryClasses(); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "About to start sending reports from SenderService"); try { final List<ReportSender> senderInstances = getSenderInstances(config, senderFactoryClasses); // Mark reports as approved if (approveReportsFirst) { markReportsAsApproved(); } // Get approved reports final File[] reports = locator.getApprovedReports(); final ReportDistributor reportDistributor = new ReportDistributor(this, config, senderInstances); // Iterate over approved reports and send via all Senders. int reportsSentCount = 0; // Use to rate limit sending final CrashReportFileNameParser fileNameParser = new CrashReportFileNameParser(); for (final File report : reports) { if (onlySendSilentReports && !fileNameParser.isSilent(report.getName())) { continue; } if (reportsSentCount >= ACRAConstants.MAX_SEND_REPORTS) { break; // send only a few reports to avoid overloading the network } reportDistributor.distribute(report); reportsSentCount++; } } catch (Exception e) { ACRA.log.e(LOG_TAG, "", e); } if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Finished sending reports from SenderService"); }
From source file:org.elasticdroid.SshConnectorView.java
/** * Called when activity is created./*from w w w.java 2 s .com*/ * @param savedInstanceState if any */ @SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //call superclass onCreate Intent intent = this.getIntent(); //get all of the data stored in the intent try { this.connectionData = (HashMap<String, String>) intent .getSerializableExtra("org.elasticdroid.EC2DashboardView.connectionData"); } catch (Exception exception) { //the possible exceptions are NullPointerException: the Hashmap was not found, or //ClassCastException: the argument passed is not Hashmap<String, String>. In either case, //just print out the error and exit. This is very inelegant, but this is a programmer's bug Log.e(TAG, exception.getMessage()); finish(); //this will cause it to return to {@link EC2DisplayInstancesView}. } securityGroupNames = intent.getStringArrayExtra("securityGroups"); hostname = intent.getStringExtra("hostname"); selectedRegion = intent.getStringExtra("selectedRegion"); // create and initialise the alert dialog alertDialogBox = new AlertDialog.Builder(this).create(); // create alert alertDialogBox.setCancelable(false); alertDialogBox.setButton(this.getString(R.string.loginview_alertdialogbox_button), new DialogInterface.OnClickListener() { // click listener on the alert box - unlock orientation when // clicked. // this is to prevent orientation changing when alert box // locked. public void onClick(DialogInterface arg0, int arg1) { alertDialogDisplayed = false; alertDialogBox.dismiss(); // dismiss dialog. // if an error occurs that is serious enough return the // user to the login // screen. THis happens due to exceptions caused by // programming errors and // exceptions caused due to invalid credentials. if (killActivityOnError) { Log.v(TAG, "Ich bin hier."); SshConnectorView.this.finish(); } } }); //initialise the display setContentView(R.layout.sshconnector); //tell the activity to set the xml file this.setTitle(connectionData.get("username") + " (" + selectedRegion + ")"); //set title View loginButton = (View) this.findViewById(R.id.sshConnectorLoginButton); loginButton.setOnClickListener(this); }
From source file:bucci.dev.freestyle.TimerActivity.java
private void initTimer() { if (DEBUG)//from w w w . j a va 2 s . c om Log.d(TAG, "initTimer()"); Intent intent = getIntent(); timerType = (TimerType) intent.getSerializableExtra(StartActivity.TIMER_TYPE); addTimerTypeToSharedPrefs(timerType); switch (timerType) { case BATTLE: startTime = BATTLE_DURATION; break; case QUALIFICATION: startTime = QUALIFICATION_DURATION; break; case ROUTINE: if (timerTextView.getText().equals(getString(R.string.song_empty))) startTime = 0; else { long duration = MediaUtils .getSongDuration(settings.getString(SAVED_SONG_PATH_PARAM, SONG_PATH_EMPTY_VALUE)); routine_duration = duration; startTime = duration; } // startTime = 5000; break; } //Small delay for airHorn/beep startTime += DELAY_FOR_BEEP; }
From source file:name.gumartinm.weather.information.fragment.current.CurrentFragment.java
@Override public void onResume() { super.onResume(); this.mReceiver = new BroadcastReceiver() { @Override//from w w w .ja v a 2 s . c o m public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); if (action.equals(BROADCAST_INTENT_ACTION)) { final Current currentRemote = (Current) intent.getSerializableExtra("current"); // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask. final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); final PermanentStorage store = new PermanentStorage(context.getApplicationContext()); final Current current = store.getCurrent(); if (current == null || !CurrentFragment.this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) { if (currentRemote != null) { // 2. Update UI. CurrentFragment.this.updateUI(currentRemote); // 3. Update current data. store.saveCurrent(currentRemote); // 4. Update location data. weatherLocation.setLastCurrentUIUpdate(new Date()); query.updateDataBase(weatherLocation); } else { // Empty UI and show error message CurrentFragment.this.getActivity().findViewById(R.id.weather_current_data_container) .setVisibility(View.GONE); CurrentFragment.this.getActivity().findViewById(R.id.weather_current_progressbar) .setVisibility(View.GONE); CurrentFragment.this.getActivity().findViewById(R.id.weather_current_error_message) .setVisibility(View.VISIBLE); } } } } }; // Register receiver final IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_INTENT_ACTION); LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()) .registerReceiver(this.mReceiver, filter); // Empty UI this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE); final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation == null) { // Nothing to do. // Show error message final ProgressBar progress = (ProgressBar) getActivity().findViewById(R.id.weather_current_progressbar); progress.setVisibility(View.GONE); final TextView errorMessage = (TextView) getActivity().findViewById(R.id.weather_current_error_message); errorMessage.setVisibility(View.VISIBLE); return; } // If is new location update widgets. if (weatherLocation.getIsNew()) { WidgetProvider.refreshAllAppWidgets(this.getActivity().getApplicationContext()); // Update location data. weatherLocation.setIsNew(false); query.updateDataBase(weatherLocation); } final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Current current = store.getCurrent(); if (current != null && this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) { this.updateUI(current); } else { // Load remote data (asynchronous) // Gets the data from the web. this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE); this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE); final CurrentTask task = new CurrentTask(this.getActivity().getApplicationContext(), new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))), new ServiceCurrentParser(new JPOSCurrentParser())); task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude()); } }
From source file:com.uzmap.pkg.uzmodules.UIMediaScanner.UIMediaScanner.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (data == null) { return;//from w ww. j a v a 2 s. c o m } @SuppressWarnings("unchecked") ArrayList<FileInfo> filelist = (ArrayList<FileInfo>) data.getSerializableExtra("files"); if (filelist != null) { mMContext.success(creatRetJSON(filelist, false), true); } }
From source file:com.nadmm.airports.wx.TafFragment.java
protected void showTaf(Intent intent) { if (getActivity() == null) { return;//from www . j ava 2 s . c o m } Taf taf = (Taf) intent.getSerializableExtra(NoaaService.RESULT); if (taf == null) { return; } View detail = findViewById(R.id.wx_detail_layout); LinearLayout layout = (LinearLayout) findViewById(R.id.wx_status_layout); TextView tv = (TextView) findViewById(R.id.status_msg); layout.removeAllViews(); if (!taf.isValid) { tv.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE); tv.setText("Unable to get TAF for this location."); addRow(layout, "This could be due to the following reasons:"); addBulletedRow(layout, "Network connection is not available"); addBulletedRow(layout, "ADDS does not publish TAF for this station"); addBulletedRow(layout, "Station is currently out of service"); addBulletedRow(layout, "Station has not updated the TAF for more than 12 hours"); detail.setVisibility(View.GONE); stopRefreshAnimation(); setFragmentContentShown(true); return; } else { tv.setText(""); tv.setVisibility(View.GONE); layout.setVisibility(View.GONE); detail.setVisibility(View.VISIBLE); } tv = (TextView) findViewById(R.id.wx_age); tv.setText(TimeUtils.formatElapsedTime(taf.issueTime)); // Raw Text tv = (TextView) findViewById(R.id.wx_raw_taf); tv.setText(taf.rawText.replaceAll("(FM|BECMG|TEMPO)", "\n $1")); layout = (LinearLayout) findViewById(R.id.taf_summary_layout); layout.removeAllViews(); String fcstType; if (taf.rawText.startsWith("TAF AMD ")) { fcstType = "Amendment"; } else if (taf.rawText.startsWith("TAF COR ")) { fcstType = "Correction"; } else { fcstType = "Normal"; } addRow(layout, "Forecast type", fcstType); addRow(layout, "Issued at", TimeUtils.formatDateTime(getActivity(), taf.issueTime)); addRow(layout, "Valid from", TimeUtils.formatDateTime(getActivity(), taf.validTimeFrom)); addRow(layout, "Valid to", TimeUtils.formatDateTime(getActivity(), taf.validTimeTo)); if (taf.remarks != null && taf.remarks.length() > 0 && !taf.remarks.equals("AMD")) { addRow(layout, "\u2022 " + taf.remarks); } LinearLayout topLayout = (LinearLayout) findViewById(R.id.taf_forecasts_layout); topLayout.removeAllViews(); StringBuilder sb = new StringBuilder(); for (Forecast forecast : taf.forecasts) { RelativeLayout grp_layout = (RelativeLayout) inflate(R.layout.grouped_detail_item); // Keep track of forecast conditions across all change groups if (mLastForecast == null || forecast.changeIndicator == null || forecast.changeIndicator.equals("FM")) { mLastForecast = forecast; } else { if (forecast.visibilitySM < Float.MAX_VALUE) { mLastForecast.visibilitySM = forecast.visibilitySM; } if (forecast.skyConditions.size() > 0) { mLastForecast.skyConditions = forecast.skyConditions; } } sb.setLength(0); if (forecast.changeIndicator != null) { sb.append(forecast.changeIndicator); sb.append(" "); } sb.append(TimeUtils.formatDateRange(getActivity(), forecast.timeFrom, forecast.timeTo)); tv = (TextView) grp_layout.findViewById(R.id.group_extra); tv.setVisibility(View.GONE); tv = (TextView) grp_layout.findViewById(R.id.group_name); tv.setText(sb.toString()); String flightCategory = WxUtils.computeFlightCategory(mLastForecast.skyConditions, mLastForecast.visibilitySM); WxUtils.setFlightCategoryDrawable(tv, flightCategory); LinearLayout fcst_layout = (LinearLayout) grp_layout.findViewById(R.id.group_details); if (forecast.probability < Integer.MAX_VALUE) { addRow(fcst_layout, "Probability", String.format("%d%%", forecast.probability)); } if (forecast.changeIndicator != null && forecast.changeIndicator.equals("BECMG")) { addRow(fcst_layout, "Becoming at", TimeUtils.formatDateTime(getActivity(), forecast.timeBecoming)); } if (forecast.windSpeedKnots < Integer.MAX_VALUE) { String wind; if (forecast.windDirDegrees == 0 && forecast.windSpeedKnots == 0) { wind = "Calm"; } else if (forecast.windDirDegrees == 0) { wind = String.format(Locale.US, "Variable at %d knots", forecast.windSpeedKnots); } else { wind = String.format(Locale.US, "%s (%s true) at %d knots", GeoUtils.getCardinalDirection(forecast.windDirDegrees), FormatUtils.formatDegrees(forecast.windDirDegrees), forecast.windSpeedKnots); } String gust = ""; if (forecast.windGustKnots < Integer.MAX_VALUE) { gust = String.format(Locale.US, "Gusting to %d knots", forecast.windGustKnots); } addRow(fcst_layout, "Winds", wind, gust); } if (forecast.visibilitySM < Float.MAX_VALUE) { String value = forecast.visibilitySM > 6 ? "6+ SM" : FormatUtils.formatStatuteMiles(forecast.visibilitySM); addRow(fcst_layout, "Visibility", value); } if (forecast.vertVisibilityFeet < Integer.MAX_VALUE) { addRow(fcst_layout, "Visibility", FormatUtils.formatFeetAgl(forecast.vertVisibilityFeet)); } for (WxSymbol wx : forecast.wxList) { addRow(fcst_layout, "Weather", wx.toString()); } for (SkyCondition sky : forecast.skyConditions) { addRow(fcst_layout, "Clouds", sky.toString()); } if (forecast.windShearSpeedKnots < Integer.MAX_VALUE) { String shear = String.format(Locale.US, "%s (%s true) at %d knots", GeoUtils.getCardinalDirection(forecast.windShearDirDegrees), FormatUtils.formatDegrees(forecast.windShearDirDegrees), forecast.windShearSpeedKnots); String height = FormatUtils.formatFeetAgl(forecast.windShearHeightFeetAGL); addRow(fcst_layout, "Wind shear", shear, height); } if (forecast.altimeterHg < Float.MAX_VALUE) { addRow(fcst_layout, "Altimeter", FormatUtils.formatAltimeter(forecast.altimeterHg)); } for (TurbulenceCondition turbulence : forecast.turbulenceConditions) { String value = WxUtils.decodeTurbulenceIntensity(turbulence.intensity); String height = FormatUtils.formatFeetRangeAgl(turbulence.minAltitudeFeetAGL, turbulence.maxAltitudeFeetAGL); addRow(fcst_layout, "Turbulence", value, height); } for (IcingCondition icing : forecast.icingConditions) { String value = WxUtils.decodeIcingIntensity(icing.intensity); String height = FormatUtils.formatFeetRangeAgl(icing.minAltitudeFeetAGL, icing.maxAltitudeFeetAGL); addRow(fcst_layout, "Icing", value, height); } topLayout.addView(grp_layout, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } tv = (TextView) findViewById(R.id.wx_fetch_time); tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), taf.fetchTime)); tv.setVisibility(View.VISIBLE); stopRefreshAnimation(); setFragmentContentShown(true); }
From source file:com.freshdigitable.udonroad.UserInfoPagerFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { final UserPageInfo reqPage = UserPageInfo.findByRequestCode(requestCode); if (reqPage == null) { super.onActivityResult(requestCode, resultCode, data); return;/*from ww w. j a v a2 s . com*/ } final long userId = getArguments().getLong(ARGS_USER_ID); final Paging paging = (Paging) data.getSerializableExtra(TimelineFragment.EXTRA_PAGING); if (reqPage.isStatus()) { final StatusRequestWorker<SortedCache<Status>> statusRequestWorker = timelineSubscriberMap.get(reqPage); if (reqPage == UserPageInfo.TWEET) { statusRequestWorker.fetchHomeTimeline(userId, paging); } else if (reqPage == UserPageInfo.FAV) { statusRequestWorker.fetchFavorites(userId, paging); } } else if (reqPage.isUser()) { final UserRequestWorker<SortedCache<User>> userRequestWorker = userSubscriberMap.get(reqPage); final long nextCursor = paging != null ? paging.getMaxId() : -1; if (reqPage == UserPageInfo.FOLLOWER) { userRequestWorker.fetchFollowers(userId, nextCursor); } else if (reqPage == UserPageInfo.FRIEND) { userRequestWorker.fetchFriends(userId, nextCursor); } } }