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.timrae.rikaidroid.MainActivity.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_AEDICT_ANALYSIS && resultCode == Activity.RESULT_OK) {
        List<HashMap<String, String>> result = (List<HashMap<String, String>>) data
                .getSerializableExtra("result");
        StringBuilder builder = getHtmlPreamble();
        addAedictItems(builder, result);
        displayHtml(builder);// w  w w  .  ja  v a  2  s. c  o  m
    }
}

From source file:com.zerobyte.lifesync.EventDisplayActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {

        if (requestCode == EDIT_EVENT) {
            HashMap<String, String> event_data = (HashMap<String, String>) data
                    .getSerializableExtra("event_data");
            ScheduleEvent se = schedule_data.get(Integer.parseInt(event_data.get("event_id")));
            se.setEvent_name(event_data.get("event_name"));
            se.setEvent_start_time(event_data.get("event_start_time"));
            se.setEvent_end_time(event_data.get("event_end_time"));
            se.setEvent_location(event_data.get("event_location"));
            se.setEvent_description(event_data.get("event_description"));
        }/*from w  ww.jav  a  2s  .  c  o m*/

        lfapp.saveSchedule(schedule_data);
        goback = true;
    }

}

From source file:eu.power_switch.gui.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // set Theme before anything else in onCreate
    ThemeHelper.applyTheme(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // allow always-on screen
    setAmbientEnabled();/*  www  .j  a va  2s .  com*/

    dataApiHandler = new DataApiHandler(getApplicationContext());

    // BroadcastReceiver to get notifications from background service if room data has changed
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d("MainActivity", "received intent: " + intent.getAction());

            if (ListenerService.DATA_UPDATED.equals(intent.getAction())) {
                ArrayList<Room> rooms = (ArrayList<Room>) intent
                        .getSerializableExtra(ListenerService.ROOM_DATA);
                replaceRoomList(rooms);

                ArrayList<Scene> scenes = (ArrayList<Scene>) intent
                        .getSerializableExtra(ListenerService.SCENE_DATA);
                replaceSceneList(scenes);
            }

            refreshUI();
        }
    };

    //        // Obtain the DismissOverlayView element
    //        dismissOverlayView = (DismissOverlayView) findViewById(R.id.dismiss_overlay);
    //        dismissOverlayView.setIntroText(R.string.long_press_intro);
    //        dismissOverlayView.showIntroIfNecessary();
    //
    //        // Configure a gesture detector
    //        gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
    //            public void onLongPress(MotionEvent ev) {
    //                dismissOverlayView.show();
    //            }
    //        });

    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {

            // Status layout
            relativeLayoutStatus = (RelativeLayout) findViewById(R.id.relativeLayout_status);
            textViewStatus = (TextView) findViewById(R.id.textView_Status);

            Button rooms = (Button) findViewById(R.id.button_rooms);
            rooms.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent startIntent = new Intent(getApplicationContext(), RoomsActivity.class);
                    startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startIntent.putExtra(ListenerService.ROOM_DATA, roomList);
                    startActivity(startIntent);
                }
            });

            Button scenes = (Button) findViewById(R.id.button_scenes);
            scenes.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent startIntent = new Intent(getApplicationContext(), ScenesActivity.class);
                    startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startIntent.putExtra(ListenerService.SCENE_DATA, sceneList);
                    startActivity(startIntent);
                }
            });

            // Get Room/Receiver/Button/Scene configuration from Smartphone App
            new FetchDataAsyncTask().execute();
        }
    });

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

        //            // Should we show an explanation?
        //            if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        //                // Show an expanation to the user *asynchronously* -- don't block
        //                // this thread waiting for the user's response! After the user
        //                // sees the explanation, try again to request the permission.
        //
        //            } else {
        //                // No explanation needed, we can request the permission.

        Log.d("Write external storage permission is missing, asking for it...");
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
        //            }
    } else {
        Log.d("Write external storage permission already granted");
    }
}

From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java

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

    getSupportActionBar().setTitle("retake");
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    Intent intent = getIntent();
    isGalleryVideo = intent.getBooleanExtra("isGalleryVideo", false);
    if (!isGalleryVideo) {
        videoMedia = (ADProcessedVideoMedia) intent.getSerializableExtra(VIDEO_PATH);
        video_filePath = videoMedia.getOutputFile().getPath();
    } else {//from   ww  w  . j  av  a2  s  . co  m
        video_filePath = intent.getStringExtra(VIDEO_PATH);
    }

    Point screenDimenions = getDisplayDimensions();

    videoView = (ADCustomVideoView) findViewById(R.id.videoView);
    videoView.setDimensions(screenDimenions.x, screenDimenions.y - screenDimenions.y / 3);
    videoView.setVideoURI(Uri.parse(video_filePath));

    playBtn = (Button) findViewById(R.id.playButton);
    playBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playVideoClip();
        }
    });

    titleTextView = (TypefaceEditText) findViewById(R.id.story_title_txt_field);

    button_save = (Button) findViewById(R.id.shareButton);
    button_save.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Util.showToast(R.string.in_progress);
        }
    });

    if (!isGalleryVideo) {
        videoSlicePanal = (LinearLayout) findViewById(R.id.videoSlicePanal);
        String sessionDirPath = videoMedia.getDirectoryPath() + "/";
        File dir = new File(sessionDirPath);
        String[] fileNames = dir.list();
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(140, 140);
        lp.setMargins(3, 3, 3, 3);
        for (int i = 0; i < fileNames.length; i++) {
            if (fileNames[i] == "output.mp4")
                continue;
            String filePath = sessionDirPath + fileNames[i];

            ADCustomVideoView vv = new ADCustomVideoView(this);
            vv.setLayoutParams(lp);
            vv.setDimensions(140, 140);
            vv.setVideoURI(Uri.parse(filePath));

            videoSlicePanal.addView(vv);
        }
    }

}

From source file:com.example.android.rowanparkingpass.Activities.PassActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pass);
    i = 0;//  ww w .j  a v  a  2s  .co m

    Intent pastIntent = getIntent();
    currentMode = pastIntent.getStringExtra(MODE);

    db = new DatabaseHandlerPasses(getApplicationContext());

    Pass pass = (Pass) pastIntent.getSerializableExtra("Pass");
    if (pass == null) {
        driver = (Driver) pastIntent.getSerializableExtra("Driver");
        vehicle = (Vehicle) pastIntent.getSerializableExtra("Vehicle");
    } else {
        driver = pass.getDriver();
        vehicle = pass.getVehicle();
    }

    setDriverView();
    setVehicleView();

    dateFormatter = new SimpleDateFormat("MM/dd/yyyy");

    startDate = (EditText) findViewById(R.id.createstartdatefield);
    startDate.setInputType(InputType.TYPE_NULL);
    startDate.setOnClickListener(this);

    endDate = (EditText) findViewById(R.id.createenddatefield);
    endDate.setInputType(InputType.TYPE_NULL);
    endDate.setOnClickListener(this);

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    calendar.set(year, month, day);

    startDate.setText(dateFormatter.format(calendar.getTime()));
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    endDate.setText(dateFormatter.format(calendar.getTime()));

    startDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            startDate.setText(dateFormatter.format(newDate.getTime()));
            try {
                Date d = newDate.getTime();
                Date d2 = dateFormatter.parse(endDate.getText().toString());
                if (d.after(d2)) {
                    newDate.add(Calendar.DAY_OF_MONTH, 1);
                    endDate.setText(dateFormatter.format(newDate.getTime()));
                }
            } catch (ParseException pe) {
                pe.printStackTrace();
            }

        }
    }, year, month, day);

    endDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            endDate.setText(dateFormatter.format(newDate.getTime()));
            try {
                Date d = newDate.getTime();
                Date d2 = dateFormatter.parse(startDate.getText().toString());
                if (d.before(d2)) {
                    newDate.add(Calendar.DAY_OF_MONTH, -1);
                    startDate.setText(dateFormatter.format(newDate.getTime()));
                }
            } catch (ParseException pe) {
                pe.printStackTrace();
            }
        }
    }, year, month, day);

    createPass = (Button) findViewById(R.id.createPassButton);
    mainMenu = (Button) findViewById(R.id.goMainMenuButton);

    createPass.setOnClickListener(this);
    mainMenu.setOnClickListener(this);
}

From source file:com.whatsoft.contactbook.activity.ProfileActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    profilePresenter = new ProfilePresenter(this);
    profilePresenter.attachView(this);
    ButterKnife.bind(this);
    Intent intent = getIntent();
    contact = (Contact) intent.getSerializableExtra(EXTRA_CONTACT);
    profileType = (ProfileType) intent.getSerializableExtra(EXTRA_TYPE);
    if (profileType == null) {
        profileType = ProfileType.VIEW;//from  ww w  .  ja v a  2  s. co m
    }

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    List<String> relationship = new ArrayList<>();
    relationship.add("Ch h");
    relationship.add("V/chng ch h");
    relationship.add("Con ");
    relationship.add("Chu");
    relationship.add("Con nui/con du/con r");
    relationship.add("B m");
    relationship.add("C quan h khc");
    ArrayAdapter<String> relationshipAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_dropdown_item, relationship);
    spnRelationship.setAdapter(relationshipAdapter);
    fillData(contact);
    switchState(profileType);
    loadBackdrop();
    setUpMap();
    Utils.setUpHideSoftKeyboard(this, findViewById(R.id.main_content));
    if (contact != null) {
        TableContact tableContact = MyApplication.getInstance().getDatabaseHelper().getTableContact();
        Contact tmp = tableContact.getRowById(contact.getId());
        if (tmp != null) {
            contact.setFavorite(tmp.isFavorite());
        }
        tableContact.insertRow(contact);
    }
}

From source file:com.nttec.everychan.ui.posting.PostingService.java

@Override
public void onStart(Intent intent, int startId) {
    if (intent == null) {
        nowPosting = false;/*from  w  w w .  j  a va2  s .c om*/
        stopSelf(startId);
        return;
    }
    currentTask = new PostingTask(startId, intent.getStringExtra(EXTRA_PAGE_HASH),
            (SendPostModel) intent.getSerializableExtra(EXTRA_SEND_POST_MODEL),
            (BoardModel) intent.getSerializableExtra(EXTRA_BOARD_MODEL));
    Async.runAsync(currentTask);
}

From source file:name.gumartinm.weather.information.fragment.overview.OverviewFragment.java

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

    this.mReceiver = new BroadcastReceiver() {

        @Override/*from   w w w  .j a v a  2 s.c om*/
        public void onReceive(final Context context, final Intent intent) {
            final String action = intent.getAction();
            if (action.equals(BROADCAST_INTENT_ACTION)) {
                final Forecast forecastRemote = (Forecast) intent.getSerializableExtra("forecast");

                // 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 Forecast forecast = store.getForecast();

                if (forecast == null
                        || !OverviewFragment.this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {

                    if (forecastRemote != null) {
                        // 2. Update UI.
                        OverviewFragment.this.updateUI(forecastRemote);

                        // 3. Update Data.
                        store.saveForecast(forecastRemote);
                        weatherLocation.setLastForecastUIUpdate(new Date());
                        query.updateDataBase(weatherLocation);

                        // 4. Show list.
                        OverviewFragment.this.setListShownNoAnimation(true);
                    } else {
                        // Empty list and show error message (see setEmptyText in onCreate)
                        OverviewFragment.this.setListAdapter(null);
                        OverviewFragment.this.setListShownNoAnimation(true);
                    }
                }
            }
        }
    };

    // Register receiver
    final IntentFilter filter = new IntentFilter();
    filter.addAction(BROADCAST_INTENT_ACTION);
    LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
            .registerReceiver(this.mReceiver, filter);

    final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
    final WeatherLocation weatherLocation = query.queryDataBase();
    if (weatherLocation == null) {
        // Nothing to do.
        // Empty list and show error message (see setEmptyText in onCreate)
        this.setListAdapter(null);
        this.setListShownNoAnimation(true);
        return;
    }

    final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
    final Forecast forecast = store.getForecast();

    if (forecast != null && this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {
        this.updateUI(forecast);
    } else {
        // Load remote data (aynchronous)
        // Gets the data from the web.
        this.setListShownNoAnimation(false);
        final OverviewTask task = new OverviewTask(this.getActivity().getApplicationContext(),
                new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))),
                new ServiceForecastParser(new JPOSForecastParser()));

        task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude());
    }
}

From source file:cmput301.f13t01.readstory.ReadFragmentActivity.java

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

    if (resultCode == RESULT_OK) {

        Intent intent = getIntent();//  ww w . j ava 2s  .  c  o m

        // receive the new annotation list from edit annotation activity
        ArrayList<Media> newAnnotationList = (ArrayList<Media>) data
                .getSerializableExtra(getResources().getString(R.string.annotation));

        storyManager.setAnnotation(fragmentId, newAnnotationList);
        // Save the story with new annotations
        save.saveStory(this.storyId, this.storyManager.getStory());

        Toast.makeText(getBaseContext(), "Annotation Saved", Toast.LENGTH_LONG).show();

        // refresh the view
        commitFragment(fragmentId);

    }

}

From source file:com.photon.phresco.nativeapp.eshop.activity.OrderReviewActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.checkout_order_review);

    initEnvironment();// w ww  . ja  v a2 s . c o  m

    Intent orderInfoIntent = getIntent();

    if (orderInfoIntent != null && (Order) orderInfoIntent.getSerializableExtra("orderObj") != null) {

        try {

            orderInfo = (Order) orderInfoIntent.getSerializableExtra("orderObj");

            displayOrderDetail();

        } catch (Exception ex) {
            PhrescoLogger.info(TAG + " - Getting Customer Details  - Exception : " + ex.toString());
            PhrescoLogger.warning(ex);
        }
    }

    backButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            try {
                goBackToPreviousActivity();
            } catch (Exception ex) {
                PhrescoLogger.info(TAG + " - backButton  - Exception : " + ex.toString());
                PhrescoLogger.warning(ex);
            }
        }
    });

    browseButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                startCategoryListActivity();
            } catch (Exception ex) {
                PhrescoLogger.info(TAG + " - browseButton  - Exception : " + ex.toString());
                PhrescoLogger.warning(ex);
            }
        }
    });

    offersButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                startOffersActivity();
            } catch (Exception ex) {
                PhrescoLogger.info(TAG + " - offersButton  - Exception : " + ex.toString());
                PhrescoLogger.warning(ex);
            }
        }
    });

    myCartButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                startMyCartActivity();
            } catch (Exception ex) {
                PhrescoLogger.info(TAG + " - myCartButton  - Exception : " + ex.toString());
                PhrescoLogger.warning(ex);
            }
        }
    });

    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                startCheckOutActivity();
            } catch (Exception ex) {
                PhrescoLogger.info(TAG + " - cancelButton  - Exception : " + ex.toString());
                PhrescoLogger.warning(ex);
            }
        }
    });

    orderSubmitButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                submitOrder();
            } catch (Exception ex) {
                PhrescoLogger.info(TAG + " - orderReviewButton  - Exception : " + ex.toString());
                PhrescoLogger.warning(ex);
            }
        }
    });
}