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.team.formal.eyeshopping.MainActivity.java

public void setRecommendedProductList() {
    Intent intent = getIntent();
    keywords = (ArrayList<String>) intent.getSerializableExtra("keywords");
    urls = (ArrayList<String>) intent.getSerializableExtra("urls");
    uris = (ArrayList<String>) intent.getSerializableExtra("uris");

    for (int i = 0; i < uris.size(); i++) {
        // get Bitmap image from uri
        try {//www .ja  v  a2 s  .  c om
            // ?  ? Uri  
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), Uri.parse(uris.get(i)));
            recommend_bitmaps.add(bitmap);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    Bitmap logo = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.splash);
    mResources[0] = logo;
    for (int i = 0; i < recommend_bitmaps.size(); i++) {
        mResources[i + 1] = recommend_bitmaps.get(i);
    }

    Bitmap default_bitmaps[] = new Bitmap[3];
    default_bitmaps[0] = BitmapFactory.decodeResource(getApplicationContext().getResources(),
            R.drawable.view_example_1);
    default_bitmaps[1] = BitmapFactory.decodeResource(getApplicationContext().getResources(),
            R.drawable.view_example_3);
    default_bitmaps[2] = BitmapFactory.decodeResource(getApplicationContext().getResources(),
            R.drawable.view_example_4);

    int default_index = 0;
    for (int i = recommend_bitmaps.size() + 1; i < mResources.length; i++) {
        mResources[i] = default_bitmaps[default_index];
        default_index++;
    }

    // View Pager  
    intro_images = (ViewPager) findViewById(R.id.pager);
    pager_indicator = (LinearLayout) findViewById(R.id.viewPagerCountDots);
    mAdapter = new ViewPagerAdapter(getApplicationContext(), mResources);
    intro_images.setAdapter(mAdapter);
    intro_images.setCurrentItem(0);
    intro_images.setOnPageChangeListener(MainActivity.this);
    setUiPageViewController();
}

From source file:org.onebusaway.android.ui.TripPlanActivity.java

@Override
protected void onResume() {
    super.onResume();

    Bundle bundle = mBuilder.getBundle();
    boolean newItineraries = false;

    // see if there is data from intent
    Intent intent = getIntent();

    if (intent != null && intent.getExtras() != null) {

        OTPConstants.Source source = (OTPConstants.Source) intent
                .getSerializableExtra(OTPConstants.INTENT_SOURCE);
        if (source != null) {

            // Copy planning params - necessary if this intent came from a notification.
            if (source == OTPConstants.Source.NOTIFICATION) {
                new TripRequestBuilder(intent.getExtras()).copyIntoBundle(bundle);
            }/* ww w  . ja  v  a2  s.co m*/

            ArrayList<Itinerary> itineraries = (ArrayList<Itinerary>) intent.getExtras()
                    .getSerializable(OTPConstants.ITINERARIES);

            if (itineraries != null) {
                bundle.putSerializable(OTPConstants.ITINERARIES, itineraries);
                newItineraries = true;
            }

            if (intent.getIntExtra(PLAN_ERROR_CODE, -1) != -1) {
                bundle.putSerializable(SHOW_ERROR_DIALOG, true);
                bundle.putInt(PLAN_ERROR_CODE, intent.getIntExtra(PLAN_ERROR_CODE, 0));
                bundle.putString(PLAN_ERROR_URL, intent.getStringExtra(PLAN_ERROR_URL));
            }

            setIntent(null);
            bundle.putBoolean(REQUEST_LOADING, false);
            mRequestLoading = false;

        }
    }

    if (mRequestLoading || bundle.getBoolean(REQUEST_LOADING)) {
        showProgressDialog();
    }

    // Check which fragment to create
    boolean haveTripPlan = bundle.getSerializable(OTPConstants.ITINERARIES) != null;

    TripPlanFragment fragment = (TripPlanFragment) getSupportFragmentManager()
            .findFragmentById(R.id.trip_plan_fragment_container);
    if (fragment == null) {
        fragment = new TripPlanFragment();
        fragment.setArguments(bundle);
        fragment.setListener(this);
        getSupportFragmentManager().beginTransaction().add(R.id.trip_plan_fragment_container, fragment)
                .commit();
    }

    mPanel = (SlidingUpPanelLayout) findViewById(R.id.trip_plan_sliding_layout);

    mPanel.setEnabled(haveTripPlan);

    if (haveTripPlan) {
        initResultsFragment();
        if (bundle.getBoolean(PANEL_STATE_EXPANDED) || newItineraries) {
            mPanel.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
        }
    }

    // show error dialog if necessary
    if (bundle.getBoolean(SHOW_ERROR_DIALOG)) {
        int planErrorCode = intent.getIntExtra(PLAN_ERROR_CODE, 0);
        String planErrorUrl = intent.getStringExtra(PLAN_ERROR_URL);
        showFeedbackDialog(planErrorCode, planErrorUrl);
    }

    if (fragment != null && intent != null) {
        fragment.setPlanErrorUrl(intent.getStringExtra(PLAN_ERROR_URL));
        fragment.setPlanRequestUrl(intent.getStringExtra(PLAN_REQUEST_URL));
    }

    // Set the height of the panel after drawing occurs.
    final ViewGroup layout = (ViewGroup) findViewById(R.id.trip_plan_fragment_container);
    ViewTreeObserver vto = layout.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            int viewHeight = mPanel.getHeight();
            int height = layout.getMeasuredHeight();
            mPanel.setPanelHeight(viewHeight - height);
        }
    });
}

From source file:com.brq.wallet.activity.AddAccountActivity.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (requestCode == ADD_ADVANCED_CODE) {
        if (resultCode == RESULT_CANCELED) {
            //stay here
            return;
        }//from  w ww  . ja  v  a  2  s.  c  o  m
        //just pass on what we got
        setResult(resultCode, intent);
        finish();
    } else if (requestCode == IMPORT_SEED_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            UUID account = (UUID) intent.getSerializableExtra(RESULT_KEY);
            finishOk(account);
        }
    } else {
        super.onActivityResult(requestCode, resultCode, intent);
    }
}

From source file:pl.bcichecki.rms.client.android.fragments.DevicesListFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE_NEW_DEVICE && resultCode == RESULT_CODE_OK) {
        downloadData();/*from   w w  w . j a va 2  s. c  om*/
    }
    if (requestCode == REQUEST_CODE_EDIT_DEVICE && resultCode == RESULT_CODE_OK) {
        Device deviceToRefresh = (Device) data.getSerializableExtra(EDIT_DEVICE_EXTRA_RET);
        refreshDevice(deviceToRefresh);
    }
}

From source file:com.microsoft.onenote.pickerlib.OneNotePickerActivity.java

private void readExtras() {
    Intent intent = getIntent();
    mNavTextColor = intent.getIntExtra("NAV_TEXT_COLOR", -1);
    mAccessToken = intent.getStringExtra("ACCESS_TOKEN");
    mThemeColor = (OneNotePickerThemeColor) intent.getSerializableExtra("THEME_COLOR");
}

From source file:com.juick.android.XMPPMessageReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
        context.startService(new Intent(context, XMPPService.class));
    }/* w  w w  . j  av a 2  s.co  m*/
    if (intent.getAction().equals(XMPPService.ACTION_MESSAGE_RECEIVED)) {
        int nMessages = intent.getIntExtra("messagesCount", 0);
        boolean sound = intent.getBooleanExtra("sound", true);
        XMPPService.IncomingMessage messag = (XMPPService.IncomingMessage) intent
                .getSerializableExtra("message");
        if (nMessages == 0)
            return;
        ArrayList<MessageReceiverListener> allListeners = (ArrayList<MessageReceiverListener>) listeners
                .clone();
        boolean handled = false;
        for (MessageReceiverListener listener : allListeners) {
            handled |= listener.onMessageReceived(messag);
        }
        if (!handled) {
            updateInfo(context, nMessages, !sound);
        }
    }
    if (intent.getAction().equals(XMPPService.ACTION_LAUNCH_MESSAGELIST)) {
        Intent nintent = new Intent(context, XMPPIncomingMessagesActivity.class);
        nintent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        nintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(nintent);
    }
}

From source file:com.racoon.ampdroid.Mp3PlayerService.java

@SuppressWarnings("unchecked")
@Override//www . jav a 2  s .c o  m
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        String action = intent.getStringExtra("ACTION");
        oCuser = intent.getStringExtra("oCuser");
        oCpassword = intent.getStringExtra("oCpassword");

        if (action != null && intent.getSerializableExtra("com.racoon.ampdroid.NowPlaying") != null) {
            playList = (ArrayList<Song>) intent.getSerializableExtra("com.racoon.ampdroid.NowPlaying");
            if (action.equals("play") && !mediaPlayer.isPlaying()) {
                cursor = intent.getIntExtra("CURSOR", 0);
                session = intent.getStringExtra("SESSION");
                play(cursor);
                Log.d("service", "cursor: " + String.valueOf(cursor));
            } else if (action.equals("pause")) {
                pause();
            } else if (action.equals("next")) {
                next();
            } else if (action.equals("previous")) {
                previous();
            }

        } else {
            // TODO error handling
        }
    }

    return 0;
}

From source file:mx.itesm.logistics.crew_tracking.fragment.ShopListFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK)
        return;/*from   w  w  w .j av a2s . c o  m*/

    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_NEW:
        sendDelivery((CDelivery) data.getSerializableExtra(DeliveryNewActivity.EXTRA_DELIVERY));
        restartTimer();
        if (mShop != null) {
            mShops.add(mShop);
            mNearby.remove(mShop);
            notifyNearbyList();
            notifyShopList();
            mShop = null;
        }
        break;
    }
}

From source file:com.smedic.tubtub.BackgroundAudioService.java

/**
 * Handles media - playlists and videos sent from fragments
 *
 * @param intent// w ww  . j  a va  2  s  .c o m
 */
private void handleMedia(Intent intent) {
    ItemType intentMediaType = ItemType.YOUTUBE_MEDIA_NONE;
    if (intent.getSerializableExtra(Config.YOUTUBE_TYPE) != null) {
        intentMediaType = (ItemType) intent.getSerializableExtra(Config.YOUTUBE_TYPE);
    }
    switch (intentMediaType) {
    case YOUTUBE_MEDIA_NONE: //video is paused,so no new playback requests should be processed
        playVideo();
        break;
    case YOUTUBE_MEDIA_TYPE_VIDEO:
        mediaType = ItemType.YOUTUBE_MEDIA_TYPE_VIDEO;
        videoItem = (YouTubeVideo) intent.getSerializableExtra(Config.YOUTUBE_TYPE_VIDEO);
        if (videoItem.getId() != null) {
            playVideo();
        }
        break;
    case YOUTUBE_MEDIA_TYPE_PLAYLIST: //new playlist playback request
        mediaType = ItemType.YOUTUBE_MEDIA_TYPE_PLAYLIST;
        youTubeVideos = (ArrayList<YouTubeVideo>) intent.getSerializableExtra(Config.YOUTUBE_TYPE_PLAYLIST);
        int startPosition = intent.getIntExtra(Config.YOUTUBE_TYPE_PLAYLIST_VIDEO_POS, 0);

        videoItem = youTubeVideos.get(startPosition);
        videoIndex = startPosition;
        playVideo();
        break;
    default:
        Log.d(TAG, "Unknown command");
        break;
    }
}

From source file:com.project.salminnella.prescoop.activity.SchoolDetailsActivity.java

/** When returning from the web activity, the preschool objects needs to sent and returned in order
 * to populate the school details again.
 *
 * @param requestCode int/*from   w  w  w.  j  ava  2s. c  o m*/
 * @param resultCode int
 * @param data Intent
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            mPreschool = (PreSchool) data.getSerializableExtra(Constants.SCHOOL_OBJECT_KEY);
        }
    }
}