android 低内存广播,android – 广播ACTION_DEVICE_STORAGE_LOW的意图是什么时候?

在我的应用程序中,我已经注册了一个广播接收器来接收系统意图ACTION_DEVICE_STORAGE_LOW.每当手机的内部记忆力都很低时,我都期待这样播出.所以,我下载了一些额外的应用程序(我的手机有一个非常小的内部存储器),导致操作系统显示系统内存不足的通知.电话剩余10 – 15 MB.但是,我的广播接收者从来没有收到这个意图.然而,系统通知停留在通知栏中,由于内部内存不足,我无法浏览互联网.

每当显示低内部存储器通知时,是否应广播这个意图?还是有一些甚至更低的内存阈值,会发出这个广播,我还没有打到我的手机?在文档中,它只说“广播操作:指示设备内存条件低的粘性广播”.既然它没有实际定义“低内存条件”,我不知道我做错了什么,或者我根本没有达到这个条件.

以下是我的BroadCastReceiver的代码:

public class MemoryBroadcastReceiver extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {

String action = intent.getAction();

if (action.equals(Intent.ACTION_MEDIA_MOUNTED)){

Log.isExternalStorageProblem = false;

Log.clearNotification(Log.externalMemoryNotificationID);

}

if (action.equals(Intent.ACTION_DEVICE_STORAGE_OK)){

Log.isInternalStorageLow = false;

Log.clearNotification(Log.internalMemoryNotificationID);

}

if(action.equals(Intent.ACTION_DEVICE_STORAGE_LOW)){

Log.isInternalStorageLow = true;

Log.displayMemoryNotification("Internal Storage Low",

"The internal storage is low, Please fix this.",

"Please clear cache and/or uninstall apps.", Log.internalMemoryNotificationID);

}

}

}

我有一个初始化接收器的服务,添加意图过滤器并注册它(除其他外):

private MemoryBroadcastReceiver memoryBroadcastReciever = new MemoryBroadcastReceiver();

public void registerBroadcastReceiver() {

IntentFilter filter = new IntentFilter();

filter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);

filter.addAction(Intent.ACTION_MEDIA_MOUNTED);

filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);

filter.addDataScheme("file");

this.getApplicationContext().registerReceiver(memoryBroadcastReciever, filter);

}

@Override

public void onCreate() {

registerBroadcastReceiver();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值