Java Code Examples for android.content.Intent.getSerializableExtra()

The following are Jave code examples for showing how to use getSerializableExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PXLSRT   File: CameraActivity.java   View Source Code Vote up 7 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == PICK_PIC_REQUEST) {
            List<String> photos = (List<String>) data.getSerializableExtra(GalleryActivity.PHOTOS);
            presenter.openCropper(photos.get(0));
        }
        if (requestCode == UCrop.REQUEST_CROP) {
            try {
                String filename = FNAME_PREFIX + System.currentTimeMillis();
                presenter.processPicture(
                        openFileOutput(filename, Context.MODE_PRIVATE), filename, UCrop.getOutput(data));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example 2
Project: appinventor-extensions   File: Texting.java   View Source Code Vote up 7 votes
/**
 * Parse the messages out of the extra fields from the "android.permission.RECEIVE_SMS" broadcast
 * intent.
 *
 * Note: This code was copied from the Android android.provider.Telephony.Sms.Intents class.
 *
 * @param intent the intent to read from
 * @return an array of SmsMessages for the PDUs
 */
public static SmsMessage[] getMessagesFromIntent(
                                                 Intent intent) {
  Object[] messages = (Object[]) intent.getSerializableExtra("pdus");
  byte[][] pduObjs = new byte[messages.length][];

  for (int i = 0; i < messages.length; i++) {
    pduObjs[i] = (byte[]) messages[i];
  }
  byte[][] pdus = new byte[pduObjs.length][];
  int pduCount = pdus.length;
  SmsMessage[] msgs = new SmsMessage[pduCount];
  for (int i = 0; i < pduCount; i++) {
    pdus[i] = pduObjs[i];
    msgs[i] = SmsMessage.createFromPdu(pdus[i]);
  }
  return msgs;
}
 
Example 3
Project: letv   File: PointsActivtiy.java   View Source Code Vote up 7 votes
public void initUI() {
    super.initUI();
    Intent intent = getIntent();
    UserBean user = (UserBean) intent.getSerializableExtra("User");
    String fromValue = intent.getStringExtra("from");
    this.pointsdraw = (Button) findViewById(R.id.pointsdraw);
    this.pointsconvert = (Button) findViewById(R.id.pointsconvert);
    this.pim_head = (RoundImageView) findViewById(R.id.pim_head);
    this.hPlay = (TextView) findViewById(R.id.iniviteNum);
    this.points_name = (TextView) findViewById(R.id.points_name);
    this.mypoints = (TextView) findViewById(R.id.mypoints);
    this.list = (ListView) findViewById(R.id.poinlist);
    if (user != null) {
        initView(user);
        getUserPointInfo();
    } else if (!TextUtils.isEmpty(fromValue) && "webview".equals(fromValue)) {
        if (PreferencesManager.getInstance().isLogin()) {
            getUserBeanTask();
        } else {
            LetvLoginActivity.launch((Activity) this, 3);
        }
    }
}
 
Example 4
Project: ITSM   File: EditInfoActivity.java   View Source Code Vote up 7 votes
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_edit_info);
  StatusBarCompat.compat(this, 0x20000000);
  ButterKnife.bind(this);
  setSupportActionBar(toolbar);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);

  Intent intent = getIntent();
  currentType = intent.getIntExtra("onClickType", CLOSE_TYPE);
  incidentDto = (IncidentDto) intent.getSerializableExtra("IncidentDto");
  if (incidentDto == null) {
    ToastUtils.showShortSafe(R.string.item_event_no_exist);
    finish();
  }
  if (CLAIM_TYPE == currentType) {
    getSupportActionBar().setTitle(R.string.item_yes_alarm);
    btnItemClaim.setText(R.string.item_yes);
  } else {
    getSupportActionBar().setTitle(R.string.item_close_alarm);
    btnItemClaim.setText(R.string.item_close);
  }
  //Serializable serializableExtra = intent.getSerializableExtra("");
}
 
Example 5
Project: CardViewSample   File: NewsActivity.java   View Source Code Vote up 7 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_news);

    newsPhoto= (ImageView) findViewById(R.id.news_info_photo);
    newsTitle= (TextView) findViewById(R.id.news_info_title);
    newsDesc= (TextView) findViewById(R.id.news_info_desc);

    Intent intent=getIntent();

    News item= (News) intent.getSerializableExtra("News");
    newsPhoto.setImageResource(item.getPhotoId());
    newsTitle.setText(item.getTitle());
    newsDesc.setText(item.getDesc());
}
 
Example 6
Project: LucaHome-AndroidApplication   File: TimerActivity.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    TimerService.TimerDownloadFinishedContent result = (TimerService.TimerDownloadFinishedContent) intent.getSerializableExtra(TimerService.TimerDownloadFinishedBroadcast);

    _progressBar.setVisibility(View.GONE);
    _searchField.setText("");
    _pullRefreshLayout.setRefreshing(false);

    if (result.Success) {
        _lastUpdateTextView.setText(TimerService.getInstance().GetLastUpdate().toString());
        updateList();
    } else {
        displayErrorSnackBar(Tools.DecompressByteArrayToString(result.Response));
        _noDataFallback.setVisibility(View.VISIBLE);
        _searchField.setVisibility(View.INVISIBLE);
    }
}
 
Example 7
Project: AndroidProgramming3e   File: CrimeFragment.java   View Source Code Vote up 6 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) {
        return;
    }

    if (requestCode == REQUEST_DATE) {
        Date date = (Date) data
                .getSerializableExtra(DatePickerFragment.EXTRA_DATE);
        mCrime.setDate(date);
        updateDate();
    }
}
 
Example 8
Project: LucaHome-AndroidApplication   File: WirelessSwitchEditActivity.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    ObjectChangeFinishedContent result = (ObjectChangeFinishedContent) intent.getSerializableExtra(WirelessSwitchService.WirelessSwitchUpdateFinishedBundle);
    if (result != null) {
        if (result.Success) {
            navigateBack("Updated Switch!");
        } else {
            displayErrorSnackBar(Tools.DecompressByteArrayToString(result.Response));
            _saveButton.setEnabled(true);
        }
    } else {
        displayErrorSnackBar("Failed to update Switch!");
        _saveButton.setEnabled(true);
    }
}
 
Example 9
Project: LucaHome-AndroidApplication   File: MeterListService.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    DownloadController.DownloadFinishedBroadcastContent content = (DownloadController.DownloadFinishedBroadcastContent) intent.getSerializableExtra(DownloadController.DownloadFinishedBundle);

    if (content.CurrentDownloadType != DownloadController.DownloadType.MeterDataDelete) {
        return;
    }

    String contentResponse = Tools.DecompressByteArrayToString(DownloadStorageService.getInstance().GetDownloadResult(content.CurrentDownloadType));

    if (contentResponse.contains("Error") || contentResponse.contains("ERROR")
            || contentResponse.contains("Canceled") || contentResponse.contains("CANCELED")
            || content.FinalDownloadState != DownloadController.DownloadState.Success) {
        Logger.getInstance().Error(TAG, contentResponse);
        sendFailedDeleteBroadcast(contentResponse);
        return;
    }

    if (!content.Success) {
        Logger.getInstance().Error(TAG, "Download was not successful!");
        sendFailedDeleteBroadcast(contentResponse);
        return;
    }

    _lastUpdate = new Date();

    _broadcastController.SendSerializableBroadcast(
            MeterDataListDeleteFinishedBroadcast,
            MeterDataListDeleteFinishedBundle,
            new ObjectChangeFinishedContent(true, new byte[]{}));

    LoadData();
}
 
Example 10
Project: letv   File: DownloadVideoAlbumPageActivity.java   View Source Code Vote up 6 votes
private void readIntent() {
    Intent intent = getIntent();
    this.curPage = intent.getIntExtra(MyDownloadActivityConfig.PAGE, 1);
    this.aid = intent.getLongExtra("aid", 0);
    this.vid = intent.getLongExtra("vid", -1);
    this.launchFrom = intent.getIntExtra("from", 2);
    this.isVideoNormal = intent.getBooleanExtra("isVideoNormal", true);
    this.album = (AlbumInfo) intent.getSerializableExtra("albumInfo");
    this.currentStream = intent.getIntExtra(TaskAddHttpRequest.stream, 1);
    this.episode = intent.getStringExtra("episode");
}
 
Example 11
Project: Nearby   File: ShowImageActivity.java   View Source Code Vote up 6 votes
private void initData(){
    Intent intent = getIntent();

    imageList = (ArrayList<String>)intent.getSerializableExtra("image");
    position = intent.getIntExtra("position", 0);
    title = intent.getStringExtra("title");

}
 
Example 12
Project: Kcb   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0 && resultCode == 0 && data != null) {
        Course course = (Course) data.getSerializableExtra("course");
        //创建课程表左边视图(节数)
        createLeftView(course);
        //创建课程表视图
        createView(course);
        //存储数据到数据库
        saveData(course);
    }
}
 
Example 13
Project: LucaHome-MediaServer   File: CurrentWeatherUpdater.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    _logger.Debug("_updateReceiver onReceive");
    WeatherModel currentWeather = (WeatherModel) intent.getSerializableExtra(OWBundles.EXTRA_WEATHER_MODEL);

    if (currentWeather != null) {
        _logger.Debug("currentWeather is: " + currentWeather.toString());

        String description = currentWeather.GetDescription();
        _logger.Debug("Description: " + description);

        WeatherCondition condition = WeatherCondition.GetByString(description);
        int iconId = condition.GetIcon();

        _logger.Debug("WeatherCondition: " + condition.toString());
        _logger.Debug("IconId: " + String.valueOf(iconId));

        CurrentWeatherModel model = new CurrentWeatherModel(
                condition.toString(),
                currentWeather.GetTemperatureString(),
                currentWeather.GetHumidity(),
                currentWeather.GetPressure(),
                currentWeather.GetLastUpdate().toString(),
                iconId,
                "",
                "",
                "",
                "");
        _logger.Debug("CurrentWeatherModel: " + model.toString());

        _broadcastController.SendSerializableBroadcast(
                Broadcasts.SHOW_CURRENT_WEATHER_MODEL,
                Bundles.CURRENT_WEATHER_MODEL,
                model);
    } else {
        _logger.Warn("Current weather is null!");
    }
}
 
Example 14
Project: AndroidProgramming3e   File: CrimeFragment.java   View Source Code Vote up 6 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) {
        return;
    }

    if (requestCode == REQUEST_DATE) {
        Date date = (Date) data
                .getSerializableExtra(DatePickerFragment.EXTRA_DATE);
        mCrime.setDate(date);
        updateDate();
    } else if (requestCode == REQUEST_CONTACT && data != null) {
        Uri contactUri = data.getData();
        // Specify which fields you want your query to return
        // values for.
        String[] queryFields = new String[]{
                ContactsContract.Contacts.DISPLAY_NAME
        };
        // Perform your query - the contactUri is like a "where"
        // clause here
        Cursor c = getActivity().getContentResolver()
                .query(contactUri, queryFields, null, null, null);
        try {
            // Double-check that you actually got results
            if (c.getCount() == 0) {
                return;
            }
            // Pull out the first column of the first row of data -
            // that is your suspect's name.
            c.moveToFirst();
            String suspect = c.getString(0);
            mCrime.setSuspect(suspect);
            mSuspectButton.setText(suspect);
        } finally {
            c.close();
        }
    }
}
 
Example 15
Project: TestChat   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
            case Constant.REQUEST_CODE_EDIT_USER_INFO:
                user = (User) data.getSerializableExtra("user");
                nick.setText(user.getNick());
                signature.setText(user.getSignature());
                Glide.with(this).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).into(icon_1);
                ToastUtils.showShortToast("保存个人信息成功");
                Glide.with(this).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).into(avatar);
                break;
            case Constant.REQUEST_CODE_WEATHER_INFO:
                LogUtil.e("返回天气数据");
                WeatherInfoBean weatherInfoBean = (WeatherInfoBean) data.getSerializableExtra("WeatherInfo");
                if (weatherInfoBean != null) {
                    mWeatherInfoBean = weatherInfoBean;
                    weatherCity.setText(mWeatherInfoBean.getCity());
                    weatherTemperature.setText(mWeatherInfoBean.getTemperature());
                }
                break;
            case Constant.REQUEST_CODE_SELECT_WALLPAPER:
                updateMenuBg();
                break;
        }
    }
}
 
Example 16
Project: LucaHome-AndroidApplication   File: BirthdayService.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    DownloadController.DownloadFinishedBroadcastContent content = (DownloadController.DownloadFinishedBroadcastContent) intent.getSerializableExtra(DownloadController.DownloadFinishedBundle);

    if (content.CurrentDownloadType != DownloadController.DownloadType.BirthdayAdd) {
        return;
    }

    String contentResponse = Tools.DecompressByteArrayToString(DownloadStorageService.getInstance().GetDownloadResult(content.CurrentDownloadType));

    if (contentResponse.contains("Error") || contentResponse.contains("ERROR")
            || contentResponse.contains("Canceled") || contentResponse.contains("CANCELED")
            || content.FinalDownloadState != DownloadController.DownloadState.Success) {
        Logger.getInstance().Error(TAG, contentResponse);
        sendFailedAddBroadcast(contentResponse);
        return;
    }

    if (!content.Success) {
        Logger.getInstance().Error(TAG, "Download was not successful!");
        sendFailedAddBroadcast(contentResponse);
        return;
    }

    _lastUpdate = new Date();

    _broadcastController.SendSerializableBroadcast(
            BirthdayAddFinishedBroadcast,
            BirthdayAddFinishedBundle,
            new ObjectChangeFinishedContent(true, Tools.CompressStringToByteArray("Add finished")));

    LoadData();
}
 
Example 17
Project: LucaHome-AndroidApplication   File: WirelessSocketService.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    DownloadController.DownloadFinishedBroadcastContent content = (DownloadController.DownloadFinishedBroadcastContent) intent.getSerializableExtra(DownloadController.DownloadFinishedBundle);

    if (content.CurrentDownloadType != DownloadController.DownloadType.WirelessSocketSet) {
        return;
    }

    String contentResponse = Tools.DecompressByteArrayToString(DownloadStorageService.getInstance().GetDownloadResult(content.CurrentDownloadType));

    if (contentResponse.contains("Error") || contentResponse.contains("ERROR")
            || contentResponse.contains("Canceled") || contentResponse.contains("CANCELED")
            || content.FinalDownloadState != DownloadController.DownloadState.Success) {
        Logger.getInstance().Error(TAG, contentResponse);
        sendFailedSocketSetBroadcast(contentResponse);
        return;
    }

    if (!content.Success) {
        Logger.getInstance().Error(TAG, "Download was not successful!");
        sendFailedSocketSetBroadcast(contentResponse);
        return;
    }

    _lastUpdate = new Date();

    _broadcastController.SendSerializableBroadcast(
            WirelessSocketSetFinishedBroadcast,
            WirelessSocketSetFinishedBundle,
            new ObjectChangeFinishedContent(true, new byte[]{}));

    LoadData();
}
 
Example 18
Project: rongyunDemo   File: DiscussionDetailActivity.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case SealConst.DISCUSSION_ADD_MEMBER_REQUEST_CODE:
                final List<String> addMember = (List<String>) data.getSerializableExtra("addDiscuMember");
                RongIMClient.getInstance().addMemberToDiscussion(targetId, addMember, new RongIMClient.OperationCallback() {
                    @Override
                    public void onSuccess() {
                        SealUserInfoManager.getInstance().getFriends(new SealUserInfoManager.ResultCallback<List<Friend>>() {
                            @Override
                            public void onSuccess(List<Friend> friendList) {
                                if (friendList != null && friendList.size() > 0) {
                                    for (Friend friend : friendList) {
                                        for (String userId : addMember) {
                                            if (userId.equals(friend.getUserId()))
                                                memberList.add(new UserInfo(userId, friend.getName(), Uri.parse(friend.getPortraitUri())));
                                        }
                                    }
                                    adapter.updateListView(memberList);
                                }
                            }

                            @Override
                            public void onError(String errString) {

                            }
                        });
                    }

                    @Override
                    public void onError(RongIMClient.ErrorCode errorCode) {

                    }
                });
                break;
            case SealConst.DISCUSSION_REMOVE_MEMBER_REQUEST_CODE:
                List<String> deleteMember = (List<String>) data.getSerializableExtra("deleteDiscuMember");
                List<UserInfo> filtered = new ArrayList<>();
                for (String id : deleteMember) {
                    int count = memberList.size();
                    for (int i = 0; i < count; i++) {
                        if (memberList.get(i).getUserId().equals(id))
                            filtered.add(memberList.get(i));
                    }
                }
                for (UserInfo userInfo : filtered) {
                    RongIMClient.getInstance().removeMemberFromDiscussion(targetId, userInfo.getUserId(), null);
                    memberList.remove(userInfo);
                }
                adapter.updateListView(memberList);
                break;
        }
    }
}
 
Example 19
Project: OSchina_resources_android   File: RegisterStepTwoActivity.java   View Source Code Vote up 5 votes
@Override
protected void initData() {
    super.initData();//必须要调用,用来注册本地广播
    Intent intent = getIntent();
    mPhoneToken = (PhoneToken) intent.getSerializableExtra(PHONE_TOKEN_KEY);
}
 
Example 20
Project: Nearby   File: SearchEmployeeActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_employee);

    Intent intent = getIntent();
    selectedPatient = (Patient)intent.getSerializableExtra("patient");

    list = new ArrayList<>();

    init();

    getEmployeeList();

}