标签:rri return bsp 单例类 ble ring 继承 launch 获取
Application全局唯一,如果需要放置全局的变量,需要用到Application,类似于OC中的单例类,获者OC中的AppDelegate
第一步:创建一个AppContext继承Application
public class AppContext extends Application {
private static AppContext instance; public static AppContext getInstance() { return instance; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); instance = this; } }
第二步:注册
<application android:name=".AppContext" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
如果我们需要获取Context:
AppContext.getInstance().getExternalFilesDir(null);
标签:rri return bsp 单例类 ble ring 继承 launch 获取
原文地址:http://www.cnblogs.com/hualuoshuijia/p/6915481.html