GVKun编程网logo

java – Android Oreo Notification崩溃系统UI(java 崩溃日志)

4

在本文中,我们将为您详细介绍java–AndroidOreoNotification崩溃系统UI的相关知识,并且为您解答关于java崩溃日志的疑问,此外,我们还会提供一些关于4月Android系统版本

在本文中,我们将为您详细介绍java – Android Oreo Notification崩溃系统UI的相关知识,并且为您解答关于java 崩溃日志的疑问,此外,我们还会提供一些关于4 月 Android 系统版本分布:8 代 Oreo 最主流、AlarmManager和BroadcastReceiver的LocalNotification未在Android O(oreo)中启动、Android 8(Oreo)上的GcmIntentService崩溃、Android 8.0 Oreo 正式亮相:各大厂商表示年底前跟进的有用信息。

本文目录一览:

java – Android Oreo Notification崩溃系统UI(java 崩溃日志)

java – Android Oreo Notification崩溃系统UI(java 崩溃日志)

我已经设法在较旧的API中使用通知,但不是Oreo.创建通知会导致我的应用程序仍能正常工作(logcat中没有消息),但是当Activity运行时,systemUI会在无限循环中崩溃并重新启动.这是systemUI进程的logcat错误:

java.lang.IllegalArgumentException: width and height must be > 0

我的代码:

private void showPlayingNotification() {
        NotificationCompat.Builder builder = mNotificationUtils.getAndroidChannelNotification(this, "Play", mMediaSessionCompat);
        if( builder == null ) {
            Log.i("Play Notification","No notification found!");
            return;
        }

        mNotificationUtils.getManager().notify(101,builder.build()); 
}

我在我创建的MediaPlayerService的onCreate中初始化了mNotificationUtils.

public class NotificationUtils extends Contextwrapper {

    private notificationmanager mManager;
    public static final String AUdio_CHANNEL_ID = "com.liftyourheads.dailyreadings.dailyReadingsAudio";
    public static final String AUdio_CHANNEL_NAME = "Daily Readings Audio Stream";

    public NotificationUtils(Context base) {
        super(base);
        createChannels();
    }

    public void createChannels() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            // create android channel
            NotificationChannel dailyReadingsAudioChannel = new NotificationChannel(AUdio_CHANNEL_ID,
                    AUdio_CHANNEL_NAME, notificationmanager.IMPORTANCE_HIGH);
            getManager().createNotificationChannel(dailyReadingsAudioChannel);

        }
    }

    public notificationmanager getManager() {
        if (mManager == null) {
            mManager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
        }
        return mManager;
    }

    public NotificationCompat.Builder getAndroidChannelNotification(Context context, String action, MediaSessionCompat mediaSession) {

        if (action.equals("Play")) {
            return MediaStyleHelper.from(context, mediaSession)
                    .addAction(new NotificationCompat.Action(android.R.drawable.ic_media_pause, "Pause", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_PLAY_PAUSE)))
                    .setStyle(
                            new android.support.v4.media.app.NotificationCompat.MediaStyle()
                                    .setShowActionsInCompactView(0)
                                    .setMediaSession(mediaSession.getSessionToken()))
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setContentText("Content Text")
                    .setContentTitle("Content Title")
                    .setChannelId(AUdio_CHANNEL_ID);

        } else if (action.equals("Pause")) {

            return MediaStyleHelper.from(context, mediaSession)
                    .addAction(new NotificationCompat.Action(android.R.drawable.ic_media_play, "Play", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_PLAY_PAUSE)))
                    .setStyle(
                            new android.support.v4.media.app.NotificationCompat.MediaStyle()
                                    .setShowActionsInCompactView(0)
                                    .setMediaSession(mediaSession.getSessionToken()))
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setContentText("Content Text")
                    .setContentTitle("Content Title")
                    .setChannelId(AUdio_CHANNEL_ID);

        }

        return null;

    } }

解决方法:

从mipmap切换到drawable图标.有关更多信息,请参见this issue

4 月 Android 系统版本分布:8 代 Oreo 最主流

4 月 Android 系统版本分布:8 代 Oreo 最主流

Google 发布了每月 Android 系统版本使用情况报告,展示了不同版本活跃用户的分布情况。

Google 通过统计用户调用 Google Play 的相关信息,确定其所使用的系统版本。可以看到,目前使用最多还是 6.0 版本,占比 16.9%,其次是 8.1,这是 8.0 的一个更新版本。

不过把更新版本都算上的话,8 代足足占有 12.9%+15.4%=28.3% 的份额;其次是 7 代 11.4%+7.8%=19.2%,Android 6 只能排到第 3。总地来看,目前主流 Android 版本是 5(Lollipop,棒棒糖)、6(Marshmallow,棉花糖)、7(Nougat,牛轧糖) 与 8(Oreo,奥利奥),另外,图表中并没有看到 Android 10 的分发情况。

这些数据是以 7 天为单位的收集的,截至 4 月 10 日,而且未显示占有率不足 0.1% 的版本。详情查看:https://developer.android.com/about/dashboards

你的 Android 设备吃上了哪种甜点?

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

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

从我所看到的广播接收器在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);
}

这是接收者代码:

public class localnotificationReceiver extends broadcastReceiver {

public static native void   nativeReceivelocalnotification (String aID, String aTitle, String aMessage, boolean aOnForeground );

/** This method receives the alarms set by localnotificationScheduler,
*   notifies the CAndroidNotifications c++ class, and (if needed) ships a notification banner 
*/
@Override
public void onReceive(Context aContext, Intent aIntent)
{
    Toast.makeText(context, text, duration).show();
}

}

Android清单:

<receiver android:name="com.category.localnotifications.localnotificationReceiver">
        <intent-filter>
            <action android:name="${applicationId}.action.LOCAL_NOTIFICATION" />
            <category android:name="com.category.localnotification" />
        </intent-filter>
    </receiver>

解决方法:

Android O是迄今为止最新的.因此,我尝试消化并提供尽可能准确的信息.

从https://developer.android.com/about/versions/oreo/background.html#broadcasts起

>针对Android 8.0或更高版本的应用无法再在其清单中为隐式广播注册广播接收器.

>应用程序可以在运行时使用Context.registerReceiver()为任何广播注册接收器,无论是隐式还是显式.

>应用可以继续在其清单中注册显式广播.

此外,在https://developer.android.com/training/scheduling/alarms.html中,示例使用显式广播,并未提及有关Android O的任何特殊内容.

我建议你尝试一下如下的明确广播吗?

public static void startAlarmbroadcastReceiver(Context context, long delay) {
    Intent _intent = new Intent(context, AlarmbroadcastReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getbroadcast(context, 0, _intent, 0);
    AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    // Remove any prevIoUs pending intent.
    alarmManager.cancel(pendingIntent);
    alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + delay, pendingIntent);        
}

AlarmbroadcastReceiver

public class AlarmbroadcastReceiver extends broadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {
    }

}

在AndroidManifest中,只需将类定义为

<receiver android:name="org.yccheok.AlarmbroadcastReceiver" >
</receiver>

Android 8(Oreo)上的GcmIntentService崩溃

Android 8(Oreo)上的GcmIntentService崩溃

我已经实现了GcmIntentService用于推送通知一切正常但是当更新版本到Android 8(Oreo)时它会在oreo设备上崩溃.是否有可能继续使用GcmIntentService进行推送通知.

请提前分享您的观点

获得例外

java.lang.RuntimeException: Unable to start receiver com.example.PushNotificationReceiver: 
java.lang.IllegalStateException: Not allowed to start service Intent {
act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.example
cmp=com.example/.pushnotification.GCMIntentService (has extras) }: 
app is in background uid UidRecord{635678a u0a186 RCVR bg:+1m44s591ms idle
procs:1 seq(0,0,0)}

解决方法:

Google already announced GCMs deprecation. Please proceed in migrating to FCM.

AL是对的,但GCM将不再像201000年4月11日那样在2019年4月11日工作.

我相信您遇到的问题与此无关,而是您试图从接收器类启动后台服务.从Android 8开始,当应用程序在前台不可见时,应用程序无法再启动后台服务.

参考:
https://developer.android.com/about/versions/oreo/android-8.0-changes#back-all

Android 8.0 Oreo 正式亮相:各大厂商表示年底前跟进

Android 8.0 Oreo 正式亮相:各大厂商表示年底前跟进

在经历四个开发者预览版的数月测试之后,Google 于今天正式命名 Android 8.0 操作系统更新为“Oreo”。

通过 Android Beta 项目渠道,Google 于今天公布了 Oreo 的系统镜像,感兴趣的尝鲜者可前往下载。Google 同时也表示在“接下来数周时间”内为 Nexus 和 Pixel 设备推送 Android 8.0 更新。

那么其他手机厂商又如何跟进呢?Google 今天表示包括 Essential、HTC、华为、京瓷(Kyocera)、摩托罗拉(Motorola)、HMD Global(Nokia)、三星、夏普和索尼都将会在年底之前发布搭载该系统的新设备或者对支持设备进行升级。

这里需要明确的是,声明中并未明确具体的上线日期,各家产品升级情况也存在差异,不排除在年底之前推出搭载 Android 8.0 的新设备;而现有设备升级需要等到 2018 年的情况。

目前掌握的信息来看,下一代 Pixel 设备将交由 HTC 和 LG 代工,应该会在接下来的几周内公布。目前 HTC 已经确认最新发布的 U11 旗舰将会获得 Android 8.0,而其他厂商暂时还未公布具体的升级规划。

来自:cnBeta.COM

我们今天的关于java – Android Oreo Notification崩溃系统UIjava 崩溃日志的分享已经告一段落,感谢您的关注,如果您想了解更多关于4 月 Android 系统版本分布:8 代 Oreo 最主流、AlarmManager和BroadcastReceiver的LocalNotification未在Android O(oreo)中启动、Android 8(Oreo)上的GcmIntentService崩溃、Android 8.0 Oreo 正式亮相:各大厂商表示年底前跟进的相关信息,请在本站查询。

本文标签: