安卓全局获取Context
16lz
2021-01-26
public class MyApplication extends Application { private static Context context; @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); } public static Context getContext(){ return context; }}
然后在xml配置文件时配置一下
就可以通过getContext()
方法获取到Context
更多相关文章
- android手势缩放
- Android(安卓)Studio之导入外部so库
- Identifying Sensors and Sensor Capabilities
- android ViewGroup左右滑屏方法2
- android测量心率的实现方法
- Html容器机制说明
- SharedPreferences使用
- android > 获取当前位置
- 获取手机联系人