小编Hug*_*Hug的帖子

AlarmManager和BroadcastReceiver的LocalNotification未在Android O(oreo)中启动

您好我已经在SDK 26之前在机器人上运行了我的本地通知

但是在Android O中我收到了以下警告,广播接收器没有被解雇.

W/BroadcastQueue: Background execution not allowed: receiving Intent { act=package.name.action.LOCAL_NOTIFICATION cat=[com.category.LocalNotification] flg=0x14 (has extras) } to package.name/com.category.localnotifications.LocalNotificationReceiver
Run Code Online (Sandbox Code Playgroud)

从我所看到的广播接收器在Android O中受到更多限制,但如果是这样,即使主要活动没有运行,我应该如何安排广播?

我应该使用服务而不是接收器吗?

这是AlarmManager启动代码:

public void Schedule(String aID, String aTitle, String aBody, int aNotificationCode, long aEpochTime)
{
    Bundle lExtras = new Bundle();
    lExtras.putInt("icon", f.getDefaultIcon());
    lExtras.putString("title", aTitle);
    lExtras.putString("message", aBody);
    lExtras.putString("id", aID);
    lExtras.putInt("requestcode", aNotificationCode);

    Intent lIntent = 
      new Intent(LocalNotificationScheduler.ACTION_NAME)
      .addCategory(NotificationsUtils.LocalNotifCategory)
      .putExtras(lExtras);

    PendingIntent lPendIntent = PendingIntent.getBroadcast(f.getApplicationContext(), aNotificationCode,
                                                           lIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager lAlarmMgr = (AlarmManager) f.getSystemService(Context.ALARM_SERVICE);
    lAlarmMgr.set(AlarmManager.RTC, 1000, lPendIntent);
}
Run Code Online (Sandbox Code Playgroud)

这是接收者代码:

public class LocalNotificationReceiver …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver alarmmanager android-8.0-oreo

20
推荐指数
2
解决办法
2万
查看次数

AAudio 或 OpenSL

我开始用 C++ 实现我的游戏音频部分,我看到有 2 个音频框架可用 AAudio ( https://developer.android.com/ndk/guides/audio/aaudio/aaudio.html ) 和OpenSL ( https://developer.android.com/ndk/guides/audio/opensl/index.html )。

这两者之间有哪些区别?

c++ audio android opensl

5
推荐指数
2
解决办法
9301
查看次数

在Android O上测试NotificationsCompat.Builder类会给我以下错误

我正在尝试使用新的Android O.

我下载了最新的sdk,在我的gradle.properties上有以下配置:

MinSDKVersion=26
TargetSDKVersion=26
CompileSDKVersion=26
Run Code Online (Sandbox Code Playgroud)

但我无法编译,因为我有以下错误:

error: cannot find symbol method setChannelId(String)
Run Code Online (Sandbox Code Playgroud)

根据谷歌这个功能是在sdk 26中引入的

任何线索?

notifications android

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