Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android NotificationManager/NotificationHelper不更新百分比值_Android_Android Notifications - Fatal编程技术网

Android NotificationManager/NotificationHelper不更新百分比值

Android NotificationManager/NotificationHelper不更新百分比值,android,android-notifications,Android,Android Notifications,所以我有一个下载东西的课程。。。我正在基于实现NotificationHelper 私有类DatabaseStorageTask扩展了AsyncTask{ 受保护的字符串doInBackground(字符串…参数){ 对于(int i=0;i,当 protected String doInBackground(String... params) { while(downloadFileCount<100){ //try while instead of for-loop

所以我有一个下载东西的课程。。。我正在基于实现NotificationHelper

私有类DatabaseStorageTask扩展了AsyncTask{
受保护的字符串doInBackground(字符串…参数){
对于(int i=0;i,当

    protected String doInBackground(String... params) {

    while(downloadFileCount<100){ //try while instead of for-loop


        downloadFileCount++;
        publishProgress(downloadFileCount); //only count downloadFileCount
    }
}
受保护的字符串doInBackground(字符串…参数){

while(downloadFileCount答案在于使用float而不是int值来获取百分比

例如,20分之5=25%

5/20=0.25

当使用int=0时 int*100=0

使用float=0.25时
float*100=25

请仔细查看我的括号…?(int)((downloadFileCount/totalDownloadFileCount)*100)在转换为int之前,我先进行100的乘法运算。这难道不能防止这种情况发生吗?请检查下面的示例:呃,谢谢您的尝试,但这完全不是我想要的……哈哈。我需要显示百分比。:)好的,对不起,现在无法测试。当我在家的时候,如果你在那之前没有找到解决方案,我会尝试一些东西……我做了一个计算日志,它是正确的。但不知怎么的,它没有发布,我不知道为什么会发生这种情况。
    protected String doInBackground(String... params) {

    while(downloadFileCount<100){ //try while instead of for-loop


        downloadFileCount++;
        publishProgress(downloadFileCount); //only count downloadFileCount
    }
}