Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.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 LED灯不亮_Android_Notifications_Led - Fatal编程技术网

Android LED灯不亮

Android LED灯不亮,android,notifications,led,Android,Notifications,Led,我正在运行一个前台服务,它偶尔会从低级本机网络程序接收数据包。目前,前台服务的静态通知以及从本机调用ffiCallback时出现的任何通知都会显示出来。但是,LED灯不会闪烁(即使弹出通知)。为什么会这样 在三星Galaxy S9上使用android SDK 30 @Override public int onStartCommand(Intent intent, int flags, int startId) { System.out.println("

我正在运行一个前台服务,它偶尔会从低级本机网络程序接收数据包。目前,前台服务的静态通知以及从本机调用
ffiCallback
时出现的任何通知都会显示出来。但是,LED灯不会闪烁(即使弹出通知)。为什么会这样

在三星Galaxy S9上使用android SDK 30

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        System.out.println("onStartCommand for Service executed ...");
        System.out.println("Starting rust subsystem!");
        String fileDir = getFilesDir().toString();
        System.out.println("Will use directory " + fileDir);
        String tag = this.start_rust_subsystem(fileDir.getBytes(StandardCharsets.UTF_8));
        System.out.println("Obtained tag: " + tag);
        PrimaryScreen.rustModel.setText(tag);
        String input = intent.getStringExtra("inputExtra");
        createNotificationChannel();

        // this intent makes the foreground icon redirect user clicks to PrimaryScreen.class
        Intent notificationIntent = new Intent(this, PrimaryScreen.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,
                0, notificationIntent, 0);
        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("Encryption Module")
                .setContentText(input)
                .setColorized(true)
                .setColor(Color.rgb(139, 113, 181))
                .setSmallIcon(R.mipmap.notification_icon2_foreground)
                .setContentIntent(pendingIntent)
                .build();

        startForeground(1, notification);
        return START_NOT_STICKY;
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        System.out.println("Service onDestroy called");
    }


    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        System.out.println("onBind called");
        return null;
    }

    private NotificationManager manager;
    private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel serviceChannel = new NotificationChannel(
                    CHANNEL_ID,
                    "Kernel",
                    NotificationManager.IMPORTANCE_DEFAULT
            );
            serviceChannel.enableLights(true);
            serviceChannel.setLightColor(Color.rgb(139, 113, 181));
            NotificationManager manager = getSystemService(NotificationManager.class);
            manager.createNotificationChannel(serviceChannel);
        }
    }

    public native byte[] send_data(byte[] bytes);
    public native String start_rust_subsystem(byte[] homeDir);

    public static ExecutorService executor = Executors.newSingleThreadExecutor();

    private int nid = 2;
    /*
        Important: We MUST offload the task to the executor above, otherwise, we block the rust kernel
        from continuing execution.
     */
    public void ffiCallback(byte[] input) {
        System.out.println("FFI Callback ran!");
        executor.submit(() -> {
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                    .setSmallIcon(R.mipmap.lusna_notification_icon2_foreground)
                    .setContentTitle("Kernel")
                    .setColorized(true)
                    .setLights(Color.rgb(139, 113, 181), 500, 2000)
                    .setColor(Color.rgb(139, 113, 181))
                    .setContentText(new String(input, StandardCharsets.UTF_8))
                    .setPriority(NotificationCompat.PRIORITY_DEFAULT);
            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

            Notification built = builder.build();
            notificationManager.notify(nid++, built);
        });
        PrimaryScreen.bundle.appendToEntry(DeveloperConsole.TAG, DeveloperConsole.TERMINAL_TEXT_TAG, new String(input, StandardCharsets.UTF_8), '\n');
        executor.submit(() -> TicketTracker.onResponseReceived(input));
    }