使用全局变量的技巧

package com.pingyijinren.test;

import android.app.Application;
import android.content.Context;

/**
 * Created by Administrator on 2016/5/20 0020.
 */
public class MyApplication extends Application{
    private static Context context;

    @Override
    public void onCreate(){
        super.onCreate();
        context=getApplicationContext();
    }

    public static Context getContext(){
        return context;
    }

}

 

posted @ 2016-05-20 11:52  zqxLonely  阅读(211)  评论(0编辑  收藏  举报