3
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:

MyData data=(MyData)getApplication();
EboMike
  • 76,846
  • 14
  • 164
  • 167
Kunal Kishore
  • 235
  • 2
  • 11

1 Answers1

0

How to declare global variables in 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

Those two might help you. Personally, I don't know the answer, but the top link appears pretty helpful.

Community
  • 1
  • 1
Reed
  • 14,703
  • 8
  • 66
  • 110