【发布时间】:2026-01-05 13:15:01
【问题描述】:
有什么方法可以捕捉/检测状态栏上系统通知的开始或实例?我打算将状态栏上显示的通知重定向到简单的 toast 或类似的东西。
【问题讨论】:
标签: android notifications statusbar
有什么方法可以捕捉/检测状态栏上系统通知的开始或实例?我打算将状态栏上显示的通知重定向到简单的 toast 或类似的东西。
【问题讨论】:
标签: android notifications statusbar
AFAIK,没有办法做到这一点。
编辑:添加示例来处理 sdcard 事件
IntentFilter f = new IntentFilter();
f.addAction(Intent.ACTION_MEDIA_EJECT);
f.addAction(Intent.ACTION_MEDIA_MOUNTED);
f.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
f.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
f.addDataScheme("file");
registerReceiver(mScanListener, f);
private BroadcastReceiver mScanListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
...
}
}
【讨论】: