According to deliver Android's development and data backhaul way steps

The step of communicating data using the bundle:

Mainactivity:

  1. Create a new Intent, and initialization
  2. Create a Bundle
  3. PutCharSequence call function key-value pair is inserted (according to the type of Value may be)
  4. Use intent.putExtras (bundle) transmitting bundle
  5. startActivity (intent) to boot activity of

Main2activity:

  1. 获取Intent:Intent intent =getIntent();
  2. 获取bundle:Bundle bundle =intent.getExtras();
  3. Use bundle.getString (key) Get value (depending on the type of Value)

Call another activity and return the result of steps:

Mainactivity:

  1. Create a new Intent, and initialization
  2. Using the startActivityForResult (intent, code) ; function and populate objects and intent parameters requestcode (code custom values, e.g. ox11)

optionActivity:

  1. Initialization intent and bundle, and to return data into a bundle
  2. intent.putExtras(bundle);
  3. Use setResult ( code , Intent); returns the content provided
  4. Finish();
Published 42 original articles · won praise 16 · views 3397

Guess you like

Origin blog.csdn.net/qq_41542638/article/details/103191999