码迷,mamicode.com
首页 > 其他好文 > 详细

StorageReceiver

时间:2020-06-16 15:08:33      阅读:44      评论:0      收藏:0      [点我收藏+]

标签:storage   ==   override   tac   androi   ide   ppc   public   RKE   

package com.android.demo.lileidemo.listener;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;

import com.android.demo.lileidemo.MyApplication;
import com.android.demo.lileidemo.constant.AppConstants;

public class StorageReceiver extends BroadcastReceiver {
private static final String TAG = AppConstants.APP_TAG + "StorageReceiver ";
private static volatile StorageReceiver mInstance;
private String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
private String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
//private static IIviStateChangeListener mIviStateChangeListener;//not static broadcast,set this to static
private Handler mWorker;

public StorageReceiver() {
mWorker = new Handler();
}

/**
* get Instance.
*
* @return instance.
*/
public static StorageReceiver getInstance() {
if (mInstance == null) {
synchronized (StorageReceiver.class) {
if (mInstance == null) {
mInstance = new StorageReceiver();
}
}
}
return mInstance;
}

// public void registerIviStateChangeListener(
// IIviStateChangeListener iviStateChangeListener) {
// LogUtil.d(TAG + "registerIviStateChangeListener()");
// mIviStateChangeListener = iviStateChangeListener;
// }

public void registerReceiver() {
//LogUtil.d(TAG + "registerReceiver ");
IntentFilter intentFilter = new IntentFilter();

intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
intentFilter.addAction(ACTION_DEVICE_STORAGE_FULL);
intentFilter.addAction(ACTION_DEVICE_STORAGE_NOT_FULL);
MyApplication.getAppContext().registerReceiver(StorageReceiver.getInstance(),
intentFilter);
}

public void unregisterReceiver() {
MyApplication.getAppContext().unregisterReceiver(StorageReceiver.getInstance());
}

@Override
public void onReceive(Context context, Intent intent) {
//LogUtil.d(TAG + "onReceive mIviStateChangeListener:" + mIviStateChangeListener);
if (intent == null) {
return;
}
String action = intent.getAction();
//LogUtil.d(TAG + "onReceive action:" + action);

}


}

StorageReceiver

标签:storage   ==   override   tac   androi   ide   ppc   public   RKE   

原文地址:https://www.cnblogs.com/adamli/p/13140684.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!