android.content.Intent.getSerializableExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中android.content.Intent.getSerializableExtra()方法的一些代码示例,展示了Intent.getSerializableExtra()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getSerializableExtra()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getSerializableExtra

Intent.getSerializableExtra介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Intent i = getIntent();
Deneme dene = (Deneme)i.getSerializableExtra("sampleObject");

代码示例来源:origin: jdamcd/android-crop

/**
 * Retrieve error that caused crop to fail
 *
 * @param result Result Intent
 * @return Throwable handled in CropImageActivity
 */
public static Throwable getError(Intent result) {
  return (Throwable) result.getSerializableExtra(Extra.ERROR);
}

代码示例来源:origin: smuyyh/BookReader

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  switch (requestCode) {
    case 1:
      if (resultCode == RESULT_OK) {
        BookSource bookSource = (BookSource) data.getSerializableExtra("source");
        bookId = bookSource._id;
      }
      //mPresenter.getBookMixAToc(bookId, "chapters");
      break;
    default:
      break;
  }
}

代码示例来源:origin: stackoverflow.com

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

  Intent intent = getIntent();
  MyInterface inter = (MyInterface) intent.getSerializableExtra("interface");

  ...
}

代码示例来源:origin: stackoverflow.com

protected void onCreate(Bundle bundle) {
  super.onCreate(savedInstanceState);

  Intent intent = getIntent();
  HashMap<String, String> hashMap = (HashMap<String, String>)intent.getSerializableExtra("map");
  Log.v("HashMapTest", hashMap.get("key"));
}

代码示例来源:origin: Tencent/tinker

public static Serializable getSerializableExtra(Intent intent, String name) {
  if (null == intent) {
    return null;
  }
  Serializable ret = null;
  try {
    ret = intent.getSerializableExtra(name);
  } catch (Exception e) {
    Log.e(TAG, "getSerializableExtra exception:" + e.getMessage());
    ret = null;
  }
  return ret;
}

代码示例来源:origin: Yalantis/uCrop

/**
 * Method retrieves error from the result intent.
 *
 * @param result crop result Intent
 * @return Throwable that could happen while image processing
 */
@Nullable
public static Throwable getError(@NonNull Intent result) {
  return (Throwable) result.getSerializableExtra(EXTRA_ERROR);
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
protected void onHandleIntent(@Nullable Intent intent) {
  if (intent == null) return;
  final Serializable serializable = intent.getSerializableExtra(KEY_CHOICE);
  if (!(serializable instanceof Choice)) return;
  Choice playerChoice = (Choice) serializable;
  handleChoice(playerChoice);
}

代码示例来源:origin: smuyyh/BookReader

@Override
public void initDatas() {
  bookListsBean = (BookLists.BookListsBean) getIntent().getSerializableExtra(INTENT_BEAN);
}

代码示例来源:origin: jeasonlzy/ImagePicker

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
    if (data != null && requestCode == 100) {
      images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
      MyAdapter adapter = new MyAdapter(images);
      gridView.setAdapter(adapter);
    } else {
      Toast.makeText(this, "没有数据", Toast.LENGTH_SHORT).show();
    }
  }
}

代码示例来源:origin: square/leakcanary

@Override protected void onHandleIntentInForeground(@Nullable Intent intent) {
 if (intent == null) {
  CanaryLog.d("HeapAnalyzerService received a null intent, ignoring.");
  return;
 }
 String listenerClassName = intent.getStringExtra(LISTENER_CLASS_EXTRA);
 HeapDump heapDump = (HeapDump) intent.getSerializableExtra(HEAPDUMP_EXTRA);
 HeapAnalyzer heapAnalyzer =
   new HeapAnalyzer(heapDump.excludedRefs, this, heapDump.reachabilityInspectorClasses);
 AnalysisResult result = heapAnalyzer.checkForLeak(heapDump.heapDumpFile, heapDump.referenceKey,
   heapDump.computeRetainedHeapSize);
 AbstractAnalysisResultService.sendResultToListener(this, listenerClassName, heapDump, result);
}

代码示例来源:origin: ACRA/acra

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
  if (intent.hasExtra(EXTRA_ACRA_CONFIG)) {
    final boolean onlySendSilentReports = intent.getBooleanExtra(EXTRA_ONLY_SEND_SILENT_REPORTS, false);
    final CoreConfiguration config = (CoreConfiguration) intent.getSerializableExtra(EXTRA_ACRA_CONFIG);
    new SendingConductor(this, config).sendReports(onlySendSilentReports);
  } else {
    if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "SenderService was started but no valid intent was delivered, will now quit");
  }
  return START_REDELIVER_INTENT;
}

代码示例来源:origin: crazycodeboy/TakePhoto

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_result_layout);
  images = (ArrayList<TImage>) getIntent().getSerializableExtra("images");
  showImg();
}

代码示例来源:origin: greenrobot/EventBus

@Override
protected void onResume() {
  super.onResume();
  if (testRunner == null) {
    TestParams testParams = (TestParams) getIntent().getSerializableExtra("params");
    testRunner = new TestRunner(getApplicationContext(), testParams, controlBus);
    if (testParams.getTestNumber() == 1) {
      textViewResult.append("Events: " + testParams.getEventCount() + "\n");
    }
    textViewResult.append("Subscribers: " + testParams.getSubscriberCount() + "\n\n");
    testRunner.start();
  }
}

代码示例来源:origin: Naoki2015/CircleDemo

private void getIntentData() {
  startPos = getIntent().getIntExtra(INTENT_POSITION, 0);
  imgUrls = getIntent().getStringArrayListExtra(INTENT_IMGURLS);
  imageSize = (ImageSize) getIntent().getSerializableExtra(INTENT_IMAGESIZE);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSerializableOfParcelableExtra() throws Exception {
 Intent intent = new Intent();
 ArrayList<Parcelable> serializable = new ArrayList<>();
 serializable.add(new TestParcelable(12));
 assertSame(intent, intent.putExtra("foo", serializable));
 assertEquals(serializable, intent.getExtras().get("foo"));
 assertEquals(serializable, intent.getSerializableExtra("foo"));
}

代码示例来源:origin: Polidea/RxAndroidBle

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_example4);
  ButterKnife.bind(this);
  String macAddress = getIntent().getStringExtra(DeviceActivity.EXTRA_MAC_ADDRESS);
  characteristicUuid = (UUID) getIntent().getSerializableExtra(EXTRA_CHARACTERISTIC_UUID);
  bleDevice = SampleApplication.getRxBleClient(this).getBleDevice(macAddress);
  connectionObservable = prepareConnectionObservable();
  //noinspection ConstantConditions
  getSupportActionBar().setSubtitle(getString(R.string.mac_address, macAddress));
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSerializableExtra() throws Exception {
 Intent intent = new Intent();
 TestSerializable serializable = new TestSerializable("some string");
 assertSame(intent, intent.putExtra("foo", serializable));
 assertEquals(serializable, intent.getExtras().get("foo"));
 assertEquals(serializable, intent.getSerializableExtra("foo"));
}

代码示例来源:origin: TommyLemon/APIJSON

@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.user_list_activity, this);
  range = getIntent().getIntExtra(INTENT_RANGE, range);
  id = getIntent().getLongExtra(INTENT_ID, id);
  search = getIntent().getStringExtra(INTENT_SEARCH);
  showSearch = getIntent().getBooleanExtra(INTENT_SHOW_SEARCH, showSearch);
  idList = (List<Long>) getIntent().getSerializableExtra(INTENT_ID_LIST);
  //功能归类分区方法,必须调用<<<<<<<<<<
  initView();
  initData();
  initEvent();
  //功能归类分区方法,必须调用>>>>>>>>>>
}

代码示例来源:origin: k9mail/k-9

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setLayout(R.layout.account_setup_check_settings);
  mMessageView = findViewById(R.id.message);
  mProgressBar = findViewById(R.id.progress);
  findViewById(R.id.cancel).setOnClickListener(this);
  setMessage(R.string.account_setup_check_settings_retr_info_msg);
  mProgressBar.setIndeterminate(true);
  String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
  mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
  mDirection = (CheckDirection) getIntent().getSerializableExtra(EXTRA_CHECK_DIRECTION);
  new CheckAccountTask(mAccount).execute(mDirection);
}

相关文章

Intent类方法