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:tw.com.geminihsu.app01.fragment.Fragment_PickUpMerchandiseStation.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
    case Constants.DEPARTURE_QUERY_GPS:
        ArrayList<Address> locationInfo = null;
        if (data != null) {
            //departure_detail = new LocationAddress();
            departure_detail = (LocationAddress) data.getSerializableExtra(Constants.BUNDLE_LOCATION);
            //String add_bookmark = data.getStringExtra(BUNDLE_KEEP_BOOMARK);
            //String latitude = data.getStringExtra(Constants.BUNDLE_MAP_LATITUDE);
            //String longitude = data.getStringExtra(Constants.BUNDLE_MAP_LONGITUDE);
            //departure_detail.setLatitude(location.getLatitude());
            //departure_detail.setLongitude(location.getLongitude());
            boolean isBookMark = data.getBooleanExtra(BUNDLE_KEEP_BOOMARK, false);
            if (isBookMark) {
                addUserLocationToBookMark(departure_detail);
            }//from   ww w  .  j a va  2 s  . c  om
            departure_address.setText(departure_detail.getAddress());
            //departure_detail.setLocation(location.getAddress());
            //departure_detail.setAddress(location.getAddress());
            /*if(add_bookmark.equals(true))
            {
                //BookMark
            }*/
            //showAddressList((ArrayList<Address>)locationInfo,departure_address,departure_detail);
        }
        break;
    case Constants.STOP_QUERY_GPS:
        //ArrayList<Address> locationInfo=null;
        if (data != null) {
            //departure_detail = new LocationAddress();
            stop_detail = (LocationAddress) data.getSerializableExtra(Constants.BUNDLE_LOCATION);
            //String add_bookmark = data.getStringExtra(BUNDLE_KEEP_BOOMARK);
            //String latitude = data.getStringExtra(Constants.BUNDLE_MAP_LATITUDE);
            //String longitude = data.getStringExtra(Constants.BUNDLE_MAP_LONGITUDE);
            //departure_detail.setLatitude(location.getLatitude());
            //departure_detail.setLongitude(location.getLongitude());
            boolean isBookMark = data.getBooleanExtra(BUNDLE_KEEP_BOOMARK, false);
            if (isBookMark) {
                addUserLocationToBookMark(stop_detail);
            }
            stop_address.setText(stop_detail.getAddress());
            //departure_detail.setLocation(location.getAddress());
            //departure_detail.setAddress(location.getAddress());
            /*if(add_bookmark.equals(true))
            {
                //BookMark
            }*/
            //showAddressList((ArrayList<Address>)locationInfo,departure_address,departure_detail);
        }
        break;
    case Constants.DESTINATION_QUERY_GPS:
        ArrayList<Address> locationInfo2 = null;
        if (data != null) {
            //destination_detail = new LocationAddress();
            destination_detail = (LocationAddress) data.getSerializableExtra(Constants.BUNDLE_LOCATION);
            //String latitude = data.getStringExtra(Constants.BUNDLE_MAP_LATITUDE);
            //String longitude = data.getStringExtra(Constants.BUNDLE_MAP_LONGITUDE);
            //destination_detail.setLatitude(Double.valueOf(latitude));
            //destination_detail.setLongitude(Double.valueOf(longitude));
            boolean isBookMark = data.getBooleanExtra(BUNDLE_KEEP_BOOMARK, false);
            if (isBookMark) {
                addUserLocationToBookMark(destination_detail);
            }
            destination_address.setText(destination_detail.getAddress());
            //destination_detail.setAddress(locationInfo2.get(0).getAddressLine(0));
            //destination_detail.setLocation(locationInfo2.get(0).getAddressLine(0));
            //showAddressList(locationInfo2,destination_address,destination_detail);
        }
        break;

    case Constants.DEPARTURE_QUERY_BOOKMARK:
        if (data != null) {
            departure_detail = new LocationAddress();
            USerBookmark uSerBookmark = (USerBookmark) data.getSerializableExtra(Constants.BUNDLE_LOCATION);
            departure_address.setText(uSerBookmark.getStreetAddress());
            departure_detail.setLongitude(Double.parseDouble(uSerBookmark.getLng()));
            departure_detail.setLatitude(Double.parseDouble(uSerBookmark.getLat()));
            departure_detail.setAddress(uSerBookmark.getStreetAddress());
            departure_detail.setLocation(uSerBookmark.getLocation());
            departure_detail.setCountryName(uSerBookmark.getCountryName());
            departure_detail.setLocality(uSerBookmark.getLocality());
            departure_detail.setZipCode(uSerBookmark.getZipCode());

        }
        break;
    case Constants.STOP_QUERY_BOOKMARK:
        if (data != null) {
            stop_detail = new LocationAddress();
            USerBookmark uSerBookmark = (USerBookmark) data.getSerializableExtra(Constants.BUNDLE_LOCATION);
            stop_address.setText(uSerBookmark.getStreetAddress());
            stop_detail.setLongitude(Double.parseDouble(uSerBookmark.getLng()));
            stop_detail.setLatitude(Double.parseDouble(uSerBookmark.getLat()));
            stop_detail.setAddress(uSerBookmark.getStreetAddress());
            stop_detail.setLocation(uSerBookmark.getLocation());
            stop_detail.setCountryName(uSerBookmark.getCountryName());
            stop_detail.setLocality(uSerBookmark.getLocality());
            stop_detail.setZipCode(uSerBookmark.getZipCode());

        }
        break;
    case Constants.DESTINATION_QUERY_BOOKMARK:
        if (data != null) {
            destination_detail = new LocationAddress();
            USerBookmark uSerBookmark1 = (USerBookmark) data.getSerializableExtra(Constants.BUNDLE_LOCATION);
            destination_address.setText(uSerBookmark1.getStreetAddress());
            destination_detail.setLongitude(Double.parseDouble(uSerBookmark1.getLng()));
            destination_detail.setLatitude(Double.parseDouble(uSerBookmark1.getLat()));
            destination_detail.setAddress(uSerBookmark1.getStreetAddress());
            destination_detail.setLocation(uSerBookmark1.getLocation());
            destination_detail.setCountryName(uSerBookmark1.getCountryName());
            destination_detail.setLocality(uSerBookmark1.getLocality());
            destination_detail.setZipCode(uSerBookmark1.getZipCode());

        }
        break;
    }
}

From source file:com.myrippleapps.mynotes.app.FragmentNotes.java

@Override
public void onActivityResult(int requestCode, int resultCode, final Intent data) {
    if (requestCode == 1) {
        if (resultCode == -1) {
            final int position = Integer.parseInt(data.getStringExtra("position"));
            adapterNote.remove(position);
            isNoteEmpty();//from  www  .j ava 2s .c o  m
            SnackbarManager.show(Snackbar.with(getActivity().getApplicationContext())
                    .text(getResources().getString(R.string.note_archived))
                    .actionColor(getResources().getColor(R.color.primary_color))
                    .duration(Snackbar.SnackbarDuration.LENGTH_SHORT)
                    .actionLabel(getResources().getString(R.string.undo).toUpperCase())
                    .actionListener(new ActionClickListener() {

                        @Override
                        public void onActionClicked(Snackbar snackbar) {
                            NoteRecord noteRecord = (NoteRecord) data.getSerializableExtra("records");
                            IDfromArchived = data.getStringExtra("ID");
                            dataSource.open();
                            dataSource.unarchivedNote(Integer.parseInt(IDfromArchived));
                            adapterNote.add(position, noteRecord);
                            layoutManager.scrollToPosition(position);
                            isNoteEmpty();
                        }
                    }).eventListener(new EventListener() {

                        @Override
                        public void onDismiss(Snackbar snackbar) {
                            fab.animate().translationYBy(snackbar.getHeight()).setDuration(470);
                        }

                        @Override
                        public void onDismissByReplace(Snackbar snackbar) {
                        }

                        @Override
                        public void onDismissed(Snackbar snackbar) {
                            fab.show();
                            fab.bringToFront();
                        }

                        @Override
                        public void onShow(Snackbar snackbar) {
                            fab.animate().translationYBy(-snackbar.getHeight());
                        }

                        @Override
                        public void onShowByReplace(Snackbar snackbar) {
                        }

                        @Override
                        public void onShown(Snackbar snackbar) {
                        }
                    }), getActivity());
        } else {
            int RESULT_DELETED = 99;
            if (resultCode == RESULT_DELETED) {
                int position = Integer.parseInt(data.getStringExtra("position"));
                adapterNote.remove(position);
                isNoteEmpty();
                SnackbarManager.show(Snackbar.with(getActivity().getApplicationContext())
                        .text(getResources().getString(2131558501))
                        .duration(Snackbar.SnackbarDuration.LENGTH_SHORT).eventListener(new EventListener() {

                            @Override
                            public void onDismiss(Snackbar snackbar) {
                                fab.animate().translationYBy(snackbar.getHeight()).setDuration(470);
                            }

                            @Override
                            public void onDismissByReplace(Snackbar snackbar) {
                            }

                            @Override
                            public void onDismissed(Snackbar snackbar) {
                            }

                            @Override
                            public void onShow(Snackbar snackbar) {
                                fab.animate().translationYBy(-snackbar.getHeight());
                            }

                            @Override
                            public void onShowByReplace(Snackbar snackbar) {
                            }

                            @Override
                            public void onShown(Snackbar snackbar) {
                            }
                        }), getActivity());
                return;
            }
            int RESULT_ADDED = 100;
            if (resultCode == RESULT_ADDED) {
                int position = Integer.parseInt(data.getStringExtra("position"));
                NoteRecord noteRecord = (NoteRecord) data.getSerializableExtra("records");
                adapterNote.notify(position, noteRecord);
                isNoteEmpty();
                return;
            }
            int RESULT_LOCK = 101;
            if (resultCode != RESULT_LOCK)
                return;
            {
                int position = Integer.parseInt(data.getStringExtra("position"));
                NoteRecord noteRecord = (NoteRecord) data.getSerializableExtra("records");
                adapterNote.notify(position, noteRecord);
            }
        }
    } else {
        if (requestCode != START_ADD_NOTE || resultCode != -1)
            return;
        {
            NoteRecord noteRecord = (NoteRecord) data.getSerializableExtra("noteRecord");
            noteRecord.setNote_id(dataSource.getLatestID());
            adapterNote.add(0, noteRecord);
            layoutManager.scrollToPosition(0);
            isNoteEmpty();
        }
    }
}

From source file:com.andreadec.musicplayer.MainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    // Called when SearchActivity returns
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == 1) { // If result code is 0, the user canceled the operation
        BrowserSong song = (BrowserSong) intent.getSerializableExtra("song");
        File songDirectory = new File(song.getPlayableUri()).getParentFile();
        BrowserDirectory browserDirectory = new BrowserDirectory(songDirectory);
        song.setBrowser(browserDirectory);
        //playSongFromSearch(song);
        searchSong = song;/*  ww w.  j ava2  s .  co  m*/
    }
}

From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == COMMENT_SEND) {
        if (data != null) {
            ORDER_INFO order = (ORDER_INFO) data.getSerializableExtra(O2OMobileAppConst.ORDERINFO);
            setOrderDetailView(order);/*from ww  w .  j a  v  a  2s. c o  m*/
        }
    } else {
        //Todo
    }
}

From source file:jp.co.tweetmap.Fragment0.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (LogUtil.isDebug())
        Log.e(TAG, "### requestCode : " + requestCode);

    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
        case MapUtil.REQUEST_CODE_FRAGMENT_0: // Called form StationSearchActivity
            Bundle bundle = data.getExtras();
            CameraPosition camerapos = new CameraPosition.Builder()
                    .target(new LatLng(bundle.getDouble("key.latitude"), bundle.getDouble("key.longitude")))
                    .zoom(15.0f).build();
            // Move camera position
            mMap.moveCamera(CameraUpdateFactory.newCameraPosition(camerapos));
            // Set current position
            mCenterPosition = camerapos;
            getNearestStation();// ww  w  .  j a  v  a2 s  . c o  m
            break;

        case MapUtil.REQUEST_CODE_TWEET_STATUS_LOADER:
            mItemList = (ArrayList<TwitterStatusItem>) data.getSerializableExtra("LIST");
            showTweetList();
            break;
        default:
            break;
        }
    }
}

From source file:jp.co.tweetmap.Fragment1.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (LogUtil.isDebug())
        Log.e(TAG, "### requestCode : " + requestCode);

    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
        case MapUtil.REQUEST_CODE_FRAGMENT_1: // Called form StationSearchActivity
            Bundle bundle = data.getExtras();
            CameraPosition camerapos = new CameraPosition.Builder()
                    .target(new LatLng(bundle.getDouble("key.latitude"), bundle.getDouble("key.longitude")))
                    .zoom(15.0f).build();
            // Move camera position
            mMap.moveCamera(CameraUpdateFactory.newCameraPosition(camerapos));
            // Set current position
            mCenterPosition = camerapos;
            getNearestStation();/*from  w  w w.  j  av  a2 s. c  o  m*/
            break;

        case MapUtil.REQUEST_CODE_TWEET_STATUS_LOADER:
            mItemList = (ArrayList<TwitterStatusItem>) data.getSerializableExtra("LIST");
            showTweetList();
            break;
        default:
            break;
        }
    }
}

From source file:jp.co.tweetmap.Fragment2.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (LogUtil.isDebug())
        Log.e(TAG, "### requestCode : " + requestCode);

    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
        case MapUtil.REQUEST_CODE_FRAGMENT_2: // Called form StationSearchActivity
            Bundle bundle = data.getExtras();
            CameraPosition camerapos = new CameraPosition.Builder()
                    .target(new LatLng(bundle.getDouble("key.latitude"), bundle.getDouble("key.longitude")))
                    .zoom(15.0f).build();
            // Move camera position
            mMap.moveCamera(CameraUpdateFactory.newCameraPosition(camerapos));
            // Set current position
            mCenterPosition = camerapos;
            getNearestStation();//from ww w  .  java  2s . c o m
            break;

        case MapUtil.REQUEST_CODE_TWEET_STATUS_LOADER:
            mItemList = (ArrayList<TwitterStatusItem>) data.getSerializableExtra("LIST");
            showTweetList();
            break;
        default:
            break;
        }
    }
}

From source file:com.gsma.rcs.ri.messaging.GroupTalkView.java

private boolean processIntent(Intent intent) {
    String action = intent.getAction();
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "processIntent: " + action);
    }//  w w  w  . java  2  s .c o  m
    String oldChatId = mChatId;
    try {
        switch ((GroupChatMode) intent.getSerializableExtra(EXTRA_MODE)) {
        case OUTGOING:
            /* Initiate a Group Chat: Get subject */
            mSubject = intent.getStringExtra(GroupTalkView.EXTRA_SUBJECT);
            updateGroupChatViewTitle(mSubject);
            /* Get the list of participants */
            ContactUtil contactUtil = ContactUtil.getInstance(this);
            List<String> contacts = intent.getStringArrayListExtra(GroupTalkView.EXTRA_PARTICIPANTS);
            if (contacts == null || contacts.isEmpty()) {
                showMessageThenExit(R.string.label_invalid_contacts);
                return false;
            }
            for (String contact : contacts) {
                mParticipants.add(contactUtil.formatContact(contact));
            }
            if (mParticipants.isEmpty()) {
                showMessageThenExit(R.string.label_invalid_contacts);
                return false;
            }
            return initiateGroupChat(oldChatId == null);

        case OPEN:
            /* Open an existing session from the history log */
            mChatId = intent.getStringExtra(GroupChatIntent.EXTRA_CHAT_ID);
            mGroupChat = mChatService.getGroupChat(mChatId);
            if (mGroupChat == null) {
                if (LogUtils.isActive) {
                    Log.e(LOGTAG, "Groupchat not found for Id=".concat(mChatId));
                }
                showMessageThenExit(R.string.label_session_not_found);
                return false;
            }
            ChatPendingIntentManager.getChatPendingIntentManager(this).clearNotification(mChatId);
            setCursorLoader(oldChatId == null);
            RI.sChatIdOnForeground = mChatId;
            mSubject = mGroupChat.getSubject();
            updateGroupChatViewTitle(mSubject);
            /* Set list of participants */
            mParticipants = mGroupChat.getParticipants().keySet();
            if (LogUtils.isActive) {
                Log.i(LOGTAG, "processIntent chatId=" + mChatId + " subject='" + mSubject + "'");
            }
            return true;

        case INCOMING:
            String rxChatId = intent.getStringExtra(GroupChatIntent.EXTRA_CHAT_ID);
            if (GroupChatIntent.ACTION_NEW_GROUP_CHAT_MESSAGE.equals(action)) {
                String rxMsgId = intent.getStringExtra(GroupChatIntent.EXTRA_MESSAGE_ID);
                mChatService.markMessageAsRead(rxMsgId);
            }
            mChatId = rxChatId;
            mGroupChat = mChatService.getGroupChat(mChatId);
            if (mGroupChat == null) {
                showMessageThenExit(R.string.label_session_not_found);
                return false;
            }
            setCursorLoader(oldChatId == null);
            RI.sChatIdOnForeground = mChatId;
            ContactId contact = mGroupChat.getRemoteContact();
            mSubject = mGroupChat.getSubject();
            updateGroupChatViewTitle(mSubject);
            mParticipants = mGroupChat.getParticipants().keySet();
            /* Display accept/reject dialog */
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "New group chat for chatId " + mChatId + " state=" + mGroupChat.getState());
            }
            if (GroupChat.State.INVITED == mGroupChat.getState()) {
                displayAcceptRejectDialog(contact);
            }
            if (LogUtils.isActive) {
                Log.d(LOGTAG, "New group chat for chatId ".concat(mChatId));
            }
            return true;
        }

    } catch (RcsServiceException e) {
        showExceptionThenExit(e);
    }
    return false;
}

From source file:com.xunlei.shortvideo.activity.VideoPublishLocal3Activity.java

@Override
public void onAction(int id, int action, Intent data) {
    super.onAction(id, action, data);
    if (id == FRAGMENT_ID_VIDEO_COVER && action == ACTION_DONE && data != null) {
        VideoSliceConfig config = (VideoSliceConfig) data
                .getSerializableExtra(VideoSliceConfig.VIDEO_SLICE_CONFIG);
        mConfig.setIndex(config.getIndex());
        mConfig.setTotal(config.getTotal());
        mConfig.setCoverOffset(config.getTime());
        mConfig.setUseCover(true);//from  w w w. j  a va 2 s.  c  om
    }

    if (id == FRAGMENT_ID_VIDEO_PERMISSION && action == ACTION_DONE && data != null) {
        mMiscConfig = (VideoMiscConfig) data.getSerializableExtra(VideoMiscConfig.VIDEO_MISC_CONFIG);
    }
}

From source file:com.geecko.QuickLyric.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    invalidateOptionsMenu();/*from w w w  .j  a  v  a 2  s  .co m*/
    LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager()
            .findFragmentByTag(LYRICS_FRAGMENT_TAG);
    if (lyricsViewFragment == null)
        return;
    if (requestCode == 77) {
        lyricsViewFragment.checkPreferencesChanges();
    } else if (resultCode == RESULT_OK && requestCode == 55) {
        Lyrics results = (Lyrics) data.getSerializableExtra("lyrics");
        updateLyricsFragment(R.animator.slide_out_end, results.getArtist(), results.getTitle(),
                results.getURL());
        lyricsViewFragment.searchResultLock = true;
    }
    lyricsViewFragment.updateSearchView(true, null, false);
}