Example usage for android.content Intent getSerializableExtra

List of usage examples for android.content Intent getSerializableExtra

Introduction

In this page you can find the example usage for android.content Intent getSerializableExtra.

Prototype

public Serializable getSerializableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.androidquery.simplefeed.fragments.FeedFragment.java

@Override
protected void init() {

    Intent intent = act.getIntent();
    if (intent != null) {
        logout = intent.getBooleanExtra("logout", false);
        source = (Entity) intent.getSerializableExtra("source");
    }/*w  ww  .j  av  a  2  s.  com*/

    if (source == null) {
        source = AppUtility.getDefaultSource();
    }

    initView();

    if (logout) {
        showLogin(true);
    } else {
        initAjax(0);
    }

}

From source file:com.sft.blackcatapp.EnrollSchoolActivity.java

@Override
protected void onActivityResult(int requestCode, final int resultCode, final Intent data) {
    if (data != null) {
        if (resultCode == R.id.base_left_btn) {
            SchoolVO school = (SchoolVO) data.getSerializableExtra("school");
            if (app.userVO != null && app.userVO.getApplystate().equals(EnrollResult.SUBJECT_NONE.getValue())
                    && school != null) {
                int position = adapter.getData().indexOf(school);
                adapter.setSelected(position);
                adapter.notifyDataSetChanged();
            }/*from  w w  w  .j ava2 s  . c  o  m*/
            return;
        }
        if (isFromMenu) {
            data.setClass(this, ApplyActivity.class);
            data.putExtra("isFromMenu", isFromMenu);
            startActivity(data);
        }
        new MyHandler(200) {
            @Override
            public void run() {
                setResult(resultCode, data);
                finish();
            }
        };
    }
}

From source file:com.android.email.activity.zx.MessageView.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.message_view);

    mSubjectView = (TextView) findViewById(R.id.subject);
    mFromView = (TextView) findViewById(R.id.from);
    mToView = (TextView) findViewById(R.id.to);
    mCcView = (TextView) findViewById(R.id.cc);
    mCcContainerView = findViewById(R.id.cc_container);
    mDateView = (TextView) findViewById(R.id.date);
    mTimeView = (TextView) findViewById(R.id.time);
    mMessageContentView = (WebView) findViewById(R.id.message_content);
    mAttachments = (LinearLayout) findViewById(R.id.attachments);
    mAttachmentIcon = (ImageView) findViewById(R.id.attachment);
    mShowPicturesSection = findViewById(R.id.show_pictures_section);
    mSenderPresenceView = (ImageView) findViewById(R.id.presence);

    mMessageContentView.setVerticalScrollBarEnabled(false);
    mAttachments.setVisibility(View.GONE);
    mAttachmentIcon.setVisibility(View.GONE);

    mFromView.setOnClickListener(this);
    mSenderPresenceView.setOnClickListener(this);
    findViewById(R.id.reply).setOnClickListener(this);
    findViewById(R.id.reply_all).setOnClickListener(this);
    findViewById(R.id.delete).setOnClickListener(this);
    findViewById(R.id.show_pictures).setOnClickListener(this);

    mMessageContentView.getSettings().setBlockNetworkImage(true);
    mMessageContentView.getSettings().setSupportZoom(false);

    setTitle("");

    mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
    mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format

    Intent intent = getIntent();
    mAccount = (Account) intent.getSerializableExtra(EXTRA_ACCOUNT);
    mFolder = intent.getStringExtra(EXTRA_FOLDER);
    mMessageUid = intent.getStringExtra(EXTRA_MESSAGE);
    mFolderUids = intent.getStringArrayListExtra(EXTRA_FOLDER_UIDS);

    View next = findViewById(R.id.next);
    View previous = findViewById(R.id.previous);
    /*/*w  w w  . j a v a2 s  .  c  om*/
     * Next and Previous Message are not shown in landscape mode, so
     * we need to check before we use them.
     */
    if (next != null && previous != null) {
        next.setOnClickListener(this);
        previous.setOnClickListener(this);

        findSurroundingMessagesUid();

        previous.setVisibility(mPreviousMessageUid != null ? View.VISIBLE : View.GONE);
        next.setVisibility(mNextMessageUid != null ? View.VISIBLE : View.GONE);

        boolean goNext = intent.getBooleanExtra(EXTRA_NEXT, false);
        if (goNext) {
            next.requestFocus();
        }
    }

    MessagingController.getInstance(getApplication()).addListener(mListener);
    new Thread() {
        @Override
        public void run() {
            // TODO this is a spot that should be eventually handled by a MessagingController
            // thread pool. We want it in a thread but it can't be blocked by the normal
            // synchronization stuff in MC.
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            MessagingController.getInstance(getApplication()).loadMessageForView(mAccount, mFolder, mMessageUid,
                    mListener);
        }
    }.start();
}

From source file:com.example.angelina.travelapp.map.MapFragment.java

@Override
@Nullable/*from w  w w.  j a  va2  s .  c om*/
public final View onCreateView(final LayoutInflater layoutInflater, final ViewGroup container,
        final Bundle savedInstance) {
    final View root = layoutInflater.inflate(R.layout.map_fragment, container, false);

    final Intent intent = getActivity().getIntent();
    // If any extra data was sent, store it.
    if (intent.getSerializableExtra("PLACE_DETAIL") != null) {
        centeredPlaceName = getActivity().getIntent().getStringExtra("PLACE_DETAIL");
    }
    if (intent.hasExtra("MIN_X")) {

        final double minX = intent.getDoubleExtra("MIN_X", 0);
        final double minY = intent.getDoubleExtra("MIN_Y", 0);
        final double maxX = intent.getDoubleExtra("MAX_X", 0);
        final double maxY = intent.getDoubleExtra("MAX_Y", 0);
        final String spatRefStr = intent.getStringExtra("SR");
        if (spatRefStr != null) {
            final Envelope envelope = new Envelope(minX, minY, maxX, maxY, SpatialReference.create(spatRefStr));
            mViewpoint = new Viewpoint(envelope);
        }
    }
    showProgressIndicator("Loading map");
    setUpMapView(root);
    return root;
}

From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details);

    baseApplication = (BaseApplication) getApplication();
    rsapi = baseApplication.getRSAPI();/*from w  w  w . ja  va2  s .c  om*/
    BahnhofsDbAdapter dbAdapter = baseApplication.getDbAdapter();
    countryCode = baseApplication.getCountryCode();
    country = dbAdapter.fetchCountryByCountryCode(countryCode);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    detailsLayout = findViewById(R.id.content_details);
    header = findViewById(R.id.header);
    tvBahnhofName = findViewById(R.id.tvbahnhofname);
    coordinates = findViewById(R.id.coordinates);
    imageView = findViewById(R.id.imageview);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onPictureClicked();
        }
    });
    takePictureButton = findViewById(R.id.button_take_picture);
    takePictureButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            takePictureWithPermissionCheck();
        }
    });
    selectPictureButton = findViewById(R.id.button_select_picture);
    selectPictureButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            selectPictureWithPermissionCheck();
        }
    });
    reportGhostStationButton = findViewById(R.id.button_remove_station);
    reportGhostStationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            reportGhostStationWithPermissionCheck();
        }
    });

    licenseTagView = findViewById(R.id.license_tag);
    licenseTagView.setMovementMethod(LinkMovementMethod.getInstance());

    // switch off image and license view until we actually have a foto
    imageView.setVisibility(View.INVISIBLE);
    licenseTagView.setVisibility(View.INVISIBLE);
    setPictureButtonsVisibility(View.INVISIBLE);

    fullscreen = false;

    readPreferences();
    Intent intent = getIntent();
    boolean directPicture = false;
    if (intent != null) {
        bahnhof = (Bahnhof) intent.getSerializableExtra(EXTRA_BAHNHOF);
        if (bahnhof == null) {
            Log.w(TAG, "EXTRA_BAHNHOF in intent data missing");
            Toast.makeText(this, R.string.station_not_found, Toast.LENGTH_LONG).show();
            finish();
            return;
        }

        directPicture = intent.getBooleanExtra(EXTRA_TAKE_FOTO, false);
        tvBahnhofName.setText(bahnhof.getTitle() + " (" + bahnhof.getId() + ")");
        coordinates.setText(bahnhof.getLat() + ", " + bahnhof.getLon());

        if (bahnhof.hasPhoto()) {
            if (ConnectionUtil.checkInternetConnection(this)) {
                BitmapCache.getInstance().getFoto(this, bahnhof.getPhotoUrl());
            }
            setPictureButtonsVisibility(
                    TextUtils.equals(nickname, bahnhof.getPhotographer()) ? View.VISIBLE : View.INVISIBLE);
        } else {
            setLocalBitmap();
        }
    }

    if (directPicture) {
        takePictureWithPermissionCheck();
    }
}

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

@SuppressWarnings("unchecked")
private void initAnnotations(Intent intent) {
    RelativeLayout relativeLayout = (RelativeLayout) findViewById(
            R.id.supersede_feedbacklibrary_annotate_image_layout);
    if (relativeLayout != null) {
        if (intent.getBooleanExtra(Utils.EXTRA_KEY_HAS_STICKER_ANNOTATIONS, false)) {
            HashMap<Integer, String> allStickerAnnotations = (HashMap<Integer, String>) intent
                    .getSerializableExtra(Utils.EXTRA_KEY_ALL_STICKER_ANNOTATIONS);
            for (Map.Entry<Integer, String> entry : allStickerAnnotations.entrySet()) {
                // Array will be of length 6 --> imageResourceId, x, y, width, height, rotation
                String[] split = entry.getValue().split(Utils.SEPARATOR);
                StickerAnnotationImageView stickerAnnotationImageView = addSticker(Integer.valueOf(split[0]));
                if (stickerAnnotationImageView != null) {
                    stickerAnnotationImageView.setX(Float.valueOf(split[1]));
                    stickerAnnotationImageView.setY(Float.valueOf(split[2]));
                    stickerAnnotationImageView.getLayoutParams().width = Integer.valueOf(split[3]);
                    stickerAnnotationImageView.getLayoutParams().height = Integer.valueOf(split[4]);
                    stickerAnnotationImageView.setRotation(Float.valueOf(split[5]));
                }/*from   w w w.  j av  a  2  s  .  c  o  m*/
            }
        }
        if (intent.getBooleanExtra(Utils.EXTRA_KEY_HAS_TEXT_ANNOTATIONS, false)) {
            HashMap<Integer, String> allTextAnnotations = (HashMap<Integer, String>) intent
                    .getSerializableExtra(Utils.EXTRA_KEY_ALL_TEXT_ANNOTATIONS);
            SortedSet<Integer> keys = new TreeSet<>(allTextAnnotations.keySet());
            for (Integer key : keys) {
                // Array will be of length 4 --> annotationText, imageResourceId, x, y
                String[] split = (allTextAnnotations.get(key)).split(Utils.SEPARATOR);
                TextAnnotationImageView textAnnotationImageView = addTextAnnotation(Integer.valueOf(split[1]));
                if (textAnnotationImageView != null) {
                    textAnnotationImageView.setAnnotationInputText(split[0]);
                    textAnnotationImageView.setX(Float.valueOf(split[2]));
                    textAnnotationImageView.setY(Float.valueOf(split[3]));
                }
            }
        }
        hideAllControlItems(relativeLayout);
    }
}

From source file:org.geometerplus.android.fbreader.network.ActivityNetworkContext.java

public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
    boolean processed = true;
    try {/*from  w  w  w  .  j a v a2 s.  c  om*/
        switch (requestCode) {
        default:
            processed = false;
            break;
        case NetworkLibraryActivity.REQUEST_ACCOUNT_PICKER:
            if (resultCode == Activity.RESULT_OK && data != null) {
                myAccount = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            }
            break;
        case NetworkLibraryActivity.REQUEST_AUTHORISATION:
            if (resultCode == Activity.RESULT_OK) {
                myAuthorizationConfirmed = true;
            }
            break;
        case NetworkLibraryActivity.REQUEST_WEB_AUTHORISATION_SCREEN:
            if (resultCode == Activity.RESULT_OK && data != null) {
                final CookieStore store = cookieStore();
                final Map<String, String> cookies = (Map<String, String>) data
                        .getSerializableExtra(NetworkLibraryActivity.COOKIES_KEY);
                if (cookies != null) {
                    for (Map.Entry<String, String> entry : cookies.entrySet()) {
                        final BasicClientCookie2 c = new BasicClientCookie2(entry.getKey(), entry.getValue());
                        c.setDomain(data.getData().getHost());
                        c.setPath("/");
                        final Calendar expire = Calendar.getInstance();
                        expire.add(Calendar.YEAR, 1);
                        c.setExpiryDate(expire.getTime());
                        c.setSecure(true);
                        c.setDiscard(false);
                        store.addCookie(c);
                    }
                }
            }
            break;
        }
    } finally {
        if (processed) {
            synchronized (this) {
                notifyAll();
            }
        }
        return processed;
    }
}

From source file:com.housekeeper.ar.healthhousekeeper.personalinfo.ModifyInfoActivity.java

@SuppressWarnings("unchecked")
@Override//from ww  w  .j a  va  2s  .  co m
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == -1) {
        selectedPicture = (ArrayList<String>) data
                .getSerializableExtra(SelectPictureActivity.INTENT_SELECTED_PICTURE);
        Log.i(TAG, "SelectedPicture:" + selectedPicture.toString());
        if (selectedPicture.size() > 0) {
            //??
            for (int i = 0; i < 1; i++) {
                Bitmap bitmap = PhotoUtils.getimage(selectedPicture.get(i));
                File file = null;
                JSONObject joRev = new JSONObject();
                httpUrl = http + upload_pic_url;
                Log.i(TAG, "post reg image url:" + httpUrl);
                if (PhotoUtils.saveBitmap2file(bitmap)) {
                    file = new File(Environment.getExternalStorageDirectory(), IMAGE_FILE_NAME);
                    joRev = HttpUtil.postImage(file, httpUrl);
                    Log.i(TAG, "post image:" + joRev.toString());
                    try {
                        if (joRev.getLong("result") == 200) {
                            String returnAddr = joRev.getString("value");
                            switch (picKind) {
                            case 0:
                                //?
                                Bitmap head_bitmap = bitmap;
                                photo.setImageBitmap(head_bitmap);
                                photoAddr = returnAddr;
                                break;
                            case 1:

                                break;

                            }
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}

From source file:com.nadmm.airports.afd.AirportDetailsFragment.java

protected void handleBroadcast(Intent intent) {
    String action = intent.getAction();
    if (action.equals(MetarService.ACTION_GET_METAR)) {
        Metar metar = (Metar) intent.getSerializableExtra(NoaaService.RESULT);
        if (metar != null && metar.rawText != null) {
            showWxInfo(metar);/*from  ww  w  .ja  v a 2  s  .  c o  m*/
            if (isRefreshing()) {
                setRefreshing(false);
            }
        }
    } else if (action.equals(DafdService.ACTION_GET_AFD)) {
        String path = intent.getStringExtra(DafdService.PDF_PATH);
        if (path != null) {
            SystemUtils.startPDFViewer(getActivity(), path);
        }
    } else if (action.equals(ClassBService.ACTION_GET_CLASSB_GRAPHIC)) {
        String path = intent.getStringExtra(ClassBService.PDF_PATH);
        if (path != null) {
            SystemUtils.startPDFViewer(getActivity(), path);
        }
    }
}

From source file:eu.power_switch.gui.fragment.configure_geofence.ConfigureGeofenceDialogPage4SummaryFragment.java

@Nullable
@Override// w ww .  ja v a 2  s .c  o  m
public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.dialog_fragment_configure_geofence_page_4, container, false);

    // BroadcastReceiver to get notifications from background service if room data has changed
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (LocalBroadcastConstants.INTENT_GEOFENCE_LOCATION_CHANGED.equals(intent.getAction())) {
                currentName = intent.getStringExtra("name");

                double latitude = intent.getDoubleExtra("latitude", Geofence.INVALID_LAT);
                double longitude = intent.getDoubleExtra("longitude", Geofence.INVALID_LON);
                currentLocation = new LatLng(latitude, longitude);

                currentGeofenceRadius = intent.getDoubleExtra("geofenceRadius", -1);

                currentSnapshot = intent.getParcelableExtra("snapshot");

            } else if (LocalBroadcastConstants.INTENT_GEOFENCE_ENTER_ACTIONS_CHANGED
                    .equals(intent.getAction())) {
                currentEnterActions = (ArrayList<Action>) intent.getSerializableExtra("actions");

            } else if (LocalBroadcastConstants.INTENT_GEOFENCE_EXIT_ACTIONS_CHANGED
                    .equals(intent.getAction())) {
                currentExitActions = (ArrayList<Action>) intent.getSerializableExtra("actions");

            }

            updateUi();

            notifyConfigurationChanged();
        }
    };

    geofenceApiHandler = new GeofenceApiHandler(getActivity());

    textViewName = (TextView) rootView.findViewById(R.id.textView_name);
    textViewLocation = (TextView) rootView.findViewById(R.id.textView_location);
    imageViewLocationSnapshot = (ImageView) rootView.findViewById(R.id.imageView_locationSnapshot);
    textViewGeofenceRadius = (TextView) rootView.findViewById(R.id.textView_geofence_radius);
    textViewEnterActions = (TextView) rootView.findViewById(R.id.textView_enter_actions);
    textViewExitActions = (TextView) rootView.findViewById(R.id.textView_exit_actions);

    Bundle args = getArguments();
    if (args != null) {
        if (args.containsKey(ConfigureApartmentGeofenceDialog.APARTMENT_ID_KEY)) {
            apartmentId = args.getLong(ConfigureApartmentGeofenceDialog.APARTMENT_ID_KEY);
        }

        if (args.containsKey(ConfigureGeofenceDialog.GEOFENCE_ID_KEY)) {
            currentId = args.getLong(ConfigureGeofenceDialog.GEOFENCE_ID_KEY);
            initializeGeofenceData(currentId);
        }
    }

    updateUi();

    return rootView;
}