This article analyzes the method of passing objects in Android development of Intent. Share it for your reference, as follows:
Method 1:
Utilization method: public Intent putExtra (String name, Parcelable value) passes a Parceable parameter, and the parameters of this method are serialized to memory.
Utilization method: public Intent putExtra (String name, Serializable value) passes an object that implements the serialized interface class, and the actual parameters of this method are serialized to disk.
Method 2:
Store data in the "Context" of the application, define the MyApplication class, let it inherit the Application class, and store references to the relevant data in MyApplication. The code is as follows:
import ; import ; public class MyApplication extends Application { public TaskInfo tastInfo; }
Configure Application in the manifest file:
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="MyApplication"> <uses-library android:name="" />
Store the data to be stored in the Application:
Intent intent = new Intent(, ); MyApplication myApp = (MyApplication) getApplication(); Object obj = lv_task_manager.getItemAtPosition(position); if(obj instanceof TaskInfo){ TaskInfo info = (TaskInfo) obj; = info; startActivity(intent); }
For more information about Android related content, please check out the topic of this site:Android development introduction and advanced tutorial》、《Android communication methods summary》、《Summary of the usage of basic Android components》、《Android View View Tips Summary》、《Android layout layout tips summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.