[英]Apart from intent is there any other way to send data across activities in android studio
Intent is useful to send data from one activity to another. 意图对于将数据从一个活动发送到另一个活动很有用。 But I want to send data from 15 components to another activity . 但是我想将数据从15个组件发送到另一个活动。 How can it be done?? 如何做呢?? Do I need to write putExtra statement 15 times? 我需要写15次putExtra语句吗?
Try something like this 试试这个
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;
}
}
You then get the object by calling ((ExampleApplication)getApplication()).getUniversalObject();
然后通过调用((ExampleApplication)getApplication()).getUniversalObject();
获得对象((ExampleApplication)getApplication()).getUniversalObject();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.