android - 我搞砸了我的 System_server 服务吗?

标签 android logging alarmmanager android-notifications

我的手机正在生成不间断的 Log.d 输出。以下内容会每秒重复 1200 次

04-25 15:58:04.883 1542-5012/? D/NetworkStatsCollection: getHistory:mUID 10266 isVideoCallUID: false

PID 1542 是 System_server,我了解到它管理着一系列 Android 服务。在我正在开发的应用程序中,我使用了警报管理器和通知服务,如下所示。我可以做些什么来使该服务按原样使用react吗?

public void scheduleNotification(Context context, long alarmTime, int notificationId, String setOrCancel) {
    EditText questionView = (EditText)findViewById(R.id.question);
    String questionText = questionView.getText().toString();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(context.getString(R.string.app_name))
            .setContentText(questionText)
            .setAutoCancel(true)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(((BitmapDrawable) context.getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap())
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

    Intent intent = new Intent(context, DashboardActivity.class);
    PendingIntent activity = PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setContentIntent(activity);

    Notification notification = builder.build();

    Intent notificationIntent = new Intent(context, TrackerNotificationService.class);
    notificationIntent.putExtra(TrackerNotificationService.NOTIFICATION_ID, notificationId);
    notificationIntent.putExtra(TrackerNotificationService.NOTIFICATION, notification);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId,
            notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    if (setOrCancel.equals("set")) {
        alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
        Log.d("Check it", "scheduleNotification: " + alarmTime);
    }else{
        alarmManager.cancel(pendingIntent);
    }

}

TrackerNotificationService.java

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class TrackerNotificationService extends BroadcastReceiver {


    public static String NOTIFICATION_ID = "notification_id";
    public static String NOTIFICATION = "notification";

    @Override
    public void onReceive(final Context context, Intent intent) {

        NotificationManager notificationManager = (NotificationManager) 
                context.getSystemService(Context.NOTIFICATION_SERVICE);

        Notification notification = intent.getParcelableExtra(NOTIFICATION);
        int notificationId = intent.getIntExtra(NOTIFICATION_ID, 0);
        notificationManager.notify(notificationId, notification);
    }
}

最佳答案

我有一台 Samsung Galaxy S7 Edge,我注意到我的 LogCat 中的 NetworkStatsCollection 垃圾邮件也开始出现在我的设备上。

this 所示发布,这似乎是一个 Core OS 进程。 设备制造商(在我的例子中是三星)一定在他们最新的操作系统更新中做了一些修改,并留下了一些调试。 非常烦人,我必须补充一下。

使用this作为临时解决方法,还可以将其报告给离您最近的三星服务中心。希望有足够的报告,他们可以快速部署修复它的操作系统更新

关于android - 我搞砸了我的 System_server 服务吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43623272/

相关文章:

java - 未从 jar 中获取 log4j.properties

java - 带有干扰器的 log4j2 配置

android - 如何取消一个 AlarmManager

android - 使用 AlarmManager 每 20 秒运行一次 Android 服务不会在从应用程序列表中终止该应用程序时重新启动

android - 应用程序关闭后 AlarmManager 不工作? - 安卓

android - 如何在 Google map 上放置图钉以及如何在 Google map 上的对话框中获取当前地址?

android - FFMPEG 构建错误 : Permission Denied

iPhone 崩溃日志?

android - 在react-native中从TypeScript调用 native 函数

java - 从 onOptionsItemSelected 显示对话框