相关疑难解决方法(0)

当我们在另一个应用程序中时,Android 10 来电通知就像什么应用程序一样

一旦我们在 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

11
推荐指数
1
解决办法
1万
查看次数

如何从锁屏启动 Android 应用程序?

是否可以在不解锁手机的情况下从锁屏启动应用程序?

每次我锁定手机并想要再次使用它时,我必须输入密码或正确的图案序列才能使用我的手机。但我想在锁屏上添加一个特定的应用程序作为快捷方式,这样我就不需要输入密码或一系列模式来打开该应用程序。

这可能吗?

我想在不解锁屏幕的情况下打开锁屏上添加的应用程序。

我尝试寻找解决方案,但似乎找不到任何解决方案。

android lockscreen

5
推荐指数
1
解决办法
6404
查看次数

Android BOOT_COMPLETED在用户超过锁定屏幕之前不会触发

我需要一个服务在我的应用程序的后台运行,我希望它在手机开机时自动启动.我有通常的BOOT_COMPLETED意图过滤器但是会发生什么......

  1. 我打开手机.
  2. 它启动直到锁定屏幕.
  3. 我通过锁屏.
  4. 后台工作开始了.

在我被要求锁定屏幕之前,我想要/需要工作.

这是在运行Android N的Pixel上.

干杯.

boot android

1
推荐指数
1
解决办法
1283
查看次数

活动从锁定屏幕开始时没有声音

这似乎是一个奇怪的问题.我正在使用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)

知道我做错了什么.

audio android alarmmanager

0
推荐指数
1
解决办法
604
查看次数