[英]how to pass data from one activity to another activity with th use of Application class
import android.app.Application;
public class MyData extends Application{
private String name;
private String phone;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
When I am using following line of code in caller Activity to send data, I get a ClassCastException: 当我在调用者Activity中使用以下代码行发送数据时,我得到一个ClassCastException:
MyData data=(MyData)getApplication();
How to declare global variables in Android? 如何在Android中声明全局变量?
or 要么
https://www.google.com/#sclient=psy-ab&hl=en&source=hp&q=extending%20application%20android&pbx=1&oq=&aq=&aqi=&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a1bc1589ec616832&biw=1680&bih=925&pf=p&pdl=500 https://www.google.com/#sclient=psy-ab&hl=en&source=hp&q=extending%20application%20android&pbx=1&oq=&aq=&aqi=&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw .r_cp。,cf.osb&FP = a1bc1589ec616832&BIW = 1680&波黑= 925&PF = p&PDL = 500
Those two might help you. 这两个可能会帮助你。 Personally, I don't know the answer, but the top link appears pretty helpful. 就个人而言,我不知道答案,但顶部链接看起来非常有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.