一些用户一直在问我的应用程序的Android锁屏小部件 - 我相信他们希望一个小部件保持在他们的锁定屏幕上,并允许他们与应用程序进行交互.
我找不到任何关于此的官方文档 - 我发现的唯一一个应用程序将带回主屏幕小部件并将它们放在锁定屏幕上.
有关构建真正的锁屏小部件的更多信息的任何线索?
某些应用程序的通知无法通过滑动来解除.
我该如何管理这种行为?
如何在没有显示通知点的情况下在android Oreo中继续后台服务?我使用通知继续我的后台服务,但我不想显示运行服务的通知.
java android push-notification android-service android-8.0-oreo
我面临在锁定屏幕上显示推送通知的问题。我能够收到通知,但无法在锁定屏幕上显示它们。
Notification notification;
notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(alarmSound)
//.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setWhen(getTimeMilliSec(timeStamp))
.setSmallIcon(R.drawable.loader)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(message)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) //to show content on lock screen
.setPriority(NotificationCompat.PRIORITY_HIGH)
.build();
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(count, notification);
Run Code Online (Sandbox Code Playgroud)
我也试过使用 PowerManager,但它只唤醒锁定屏幕,但没有在屏幕上显示通知。
PowerManager powerManager = (PowerManager) mContext.getSystemService(POWER_SERVICE);
if (!powerManager.isInteractive()){ // if screen is not already on, turn it on (get wake_lock for 10 seconds)
PowerManager.WakeLock wl = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE,"MH24_SCREENLOCK");
wl.acquire(10000);
PowerManager.WakeLock wl_cpu = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MH24_SCREENLOCK");
wl_cpu.acquire(10000);
}
Run Code Online (Sandbox Code Playgroud)
由于我是 android 新手,我无法解决这个问题。请帮帮我。