Intent对于将数据从一个活动发送到另一个活动非常有用。但我想将15个组件的数据发送到另一个活动。怎么做到呢??我需要写15次putExtra语句吗?
答案 0 :(得分:3)
尝试这样的事情
package com.example;
import android.app.Application;
public class ExampleApplication extends Application {
//Used to pass data between activity components.
private Object universalObject = null;//Can be any type at all
public void setUniversalObject(Object a) {
this.universalObject = a;
}
public Object getUniversalObject() {
return a;
}
}
然后通过调用((ExampleApplication)getApplication()).getUniversalObject();