How to declare global variables in Android?

前端 未结 17 3031
死守一世寂寞
死守一世寂寞 2020-11-21 04:12

I am creating an application which requires login. I created the main and the login activity.

In the main activity onCreate method I added the following

17条回答
  •  青春惊慌失措
    2020-11-21 05:07

    Create this subclass

    public class MyApp extends Application {
      String foo;
    }
    

    In the AndroidManifest.xml add android:name

    Example

    
    

提交回复
热议问题