• 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
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;
    }
}
 
Back
Top Bottom