package com.xscm.moduleutil.service; import android.content.Context; import android.os.Handler; import java.lang.ref.WeakReference; public class HandlerUtil extends Handler { private static HandlerUtil instance = null; WeakReference mActivityReference; public static HandlerUtil getInstance(Context context) { if (instance == null) { instance = new HandlerUtil(context.getApplicationContext()); } return instance; } HandlerUtil(Context context) { mActivityReference = new WeakReference<>(context); } }