• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps global variable ==> Extending Application ???

aryaxt

Newbie
Jun 1, 2010
21
0
I am trying to implement a class extending the application to keep my global variables. I get an error
Code:
public class MyApp extends Application {
    public String username;
    public String session;
    public String key;
}
//when debugging and trying to go through line 6 the debugger says: source not found , and there is a button that says "Edit source lookup path"
Code:
public class MyActivity extends Activity {
@Override    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loader);        
        MyApp app = ((MyApp)getApplicationContext());
        //when debugging and trying to go through the line above the debugger says: source not found , and there is a button that says "Edit source lookup path"
        String username = app.username;
    }
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones