一旦我们在 android 10 后台启动活动受限时收到 FCM 推送通知消息。当我们在另一个应用程序中时,需要像 WhatsApp 和 Skype 通知来电这样的解决方案。
int NOTIFICATIONID = 1234;
// Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.capv_callingtone);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
String CHANNEL_ID = BuildConfig.APPLICATION_ID.concat("_notification_id");
String CHANNEL_NAME = BuildConfig.APPLICATION_ID.concat("_notification_name");
assert notificationManager != null;
NotificationChannel mChannel = notificationManager.getNotificationChannel(CHANNEL_ID);
if (mChannel == null) {
mChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
mChannel.setSound(sound, audioAttributes);
notificationManager.createNotificationChannel(mChannel);
}
in.setClass(CapVFirebaseMessagingService.this, DashBoardActivity.class); …Run Code Online (Sandbox Code Playgroud) android android-notifications whatsapp firebase-cloud-messaging
是否可以在不解锁手机的情况下从锁屏启动应用程序?
每次我锁定手机并想要再次使用它时,我必须输入密码或正确的图案序列才能使用我的手机。但我想在锁屏上添加一个特定的应用程序作为快捷方式,这样我就不需要输入密码或一系列模式来打开该应用程序。
这可能吗?
我想在不解锁屏幕的情况下打开锁屏上添加的应用程序。
我尝试寻找解决方案,但似乎找不到任何解决方案。
我需要一个服务在我的应用程序的后台运行,我希望它在手机开机时自动启动.我有通常的BOOT_COMPLETED意图过滤器但是会发生什么......
在我被要求锁定屏幕之前,我想要/需要工作.
这是在运行Android N的Pixel上.
干杯.
这似乎是一个奇怪的问题.我正在使用AlarmManager设置自定义音轨的闹钟.活动开始并正常播放音乐,但是当我锁定电话时,活动开始但音频没有播放.
这是我正在使用它的代码.
onCreate方法
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakelock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,"My Wake Log");
mWakelock.acquire();
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
setContentView(R.layout.sampleAlarm);
mediplayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediplayer.setDataSource(Environment.getExternalStorageDirectory()+"track1/1.mp3");
mediplayer.setVolume(100,100);
mediplayer.prepare();
mediplayer.setLooping(true);
mediplayer.start();
Run Code Online (Sandbox Code Playgroud)
知道我做错了什么.