在构建通知

时间:2016-09-19 09:15:46

标签: android notifications xamarin.android android-theme cyanogenmod

我在我的应用中使用了显示进度的通知,并且我已经构建了一个类,可以轻松地为我处理通知更新。

对于构造函数,我传递一个上下文,以便能够构建通知。以下是更新进度通知的方法:

public void ReportProgress(int percentage, string title, string content, int icon = Resource.Drawable.Icon)
{

    builder = new Notification.Builder(c)
        .SetContentText(content)
        .SetContentTitle(title)
        .SetSmallIcon(icon)
        .SetProgress(100, percentage, false)
        .SetOngoing(true);

    notificationManager.Notify(notificationId, builder.Build());
}  

我保留了相同的通知ID,因此我可以更新现有的通知,而不是创建新的通知。我已经看到警告也会定期发出通知,但随着进度的发展最为明显,因为那里有更多的更新。

以下是警告日志:

09-19 11:49:44.754 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:44.806 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:44.863 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:44.887 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:44.940 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:44.973 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.006 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.051 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.089 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.127 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.175 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.232 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.291 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.336 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png
09-19 11:49:45.372 W/IconPackHelper(17467): Unable to cache icon /data/system/theme/icons/com.App_7f020002_0.png

重要提示请注意,此警告仅在我在我的真实手机上进行测试时出现,即运行最新更新cm-13.0-20160921-NIGHTLY ,我已经使用了多个模拟器并且没有发生错误。我还没有机会在另一部带有cyanoegenmod的手机上测试它。

每当我更新通知(100+)时它都会发生。我怎么能阻止这个错误?为什么会这样?它应该关注我吗?

修改

我已经确认IconPackHelper是cyanogenmod主题服务的一部分,这里是它的来源IconCacheManagerService

这是来自logcat的实际日志,它崩溃了,因为它没有访问该文件的权限(?)。

09-21 16:33:44.002: W/IconCacheManagerService(6389): Unable to cache icon com.App_7f020002_0.png
09-21 16:33:44.002: W/IconCacheManagerService(6389): java.io.FileNotFoundException: /data/system/theme/icons/com.App_7f020002_0.png: open failed: EACCES (Permission denied)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at libcore.io.IoBridge.open(IoBridge.java:452)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at java.io.FileOutputStream.<init>(FileOutputStream.java:72)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at org.cyanogenmod.themeservice.IconCacheManagerService$2.cacheComposedIcon(IconCacheManagerService.java:75)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at org.cyanogenmod.internal.themes.IIconCacheManager$Stub.onTransact(IIconCacheManager.java:58)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at android.os.Binder.execTransact(Binder.java:453)
09-21 16:33:44.002: W/IconCacheManagerService(6389): Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at libcore.io.Posix.open(Native Method)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    at libcore.io.IoBridge.open(IoBridge.java:438)
09-21 16:33:44.002: W/IconCacheManagerService(6389):    ... 5 more

1 个答案:

答案 0 :(得分:-1)

你正在使用带有cyanogenMod的手机吗?