gpt4 book ai didi

android - java.lang.NoSuchMethodError : android. 应用程序通知$Builder.setColor

转载 作者:太空狗 更新时间:2023-10-29 15:38:13 27 4
gpt4 key购买 nike

final Notification.Builder mBuilder = new Notification.Builder(this)
.setSmallIcon(R.drawable.bwf_logo)
.setColor(getResources().getColor(android.R.color.white)) // **exception raised at this line**
.setContentTitle("Title")
.setStyle(
new Notification.BigTextStyle()
.bigText(notificationMessage))
.setAutoCancel(true)
.setSound(
RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setVibrate(vibrate).setContentText(notificationMessage);

mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());

01-17 21:14:44.450: W/dalvikvm(27472): threadid=38: thread exiting with uncaught exception (group=0x41004318)
01-17 21:14:44.450: E/AndroidRuntime(27472): FATAL EXCEPTION: IntentService[GCMIntentService]
01-17 21:14:44.450: E/AndroidRuntime(27472): java.lang.NoSuchMethodError: android.app.Notification$Builder.setColor
01-17 21:14:44.450: E/AndroidRuntime(27472): at com.bwf.betswithfriends.GCMIntentService.gcmAlternateStakeNotification(GCMIntentService.java:109)
01-17 21:14:44.450: E/AndroidRuntime(27472): at com.bwf.betswithfriends.GCMIntentService.onHandleIntent(GCMIntentService.java:51)
01-17 21:14:44.450: E/AndroidRuntime(27472): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
01-17 21:14:44.450: E/AndroidRuntime(27472): at android.os.Handler.dispatchMessage(Handler.java:99)
01-17 21:14:44.450: E/AndroidRuntime(27472): at android.os.Looper.loop(Looper.java:137)
01-17 21:14:44.450: E/AndroidRuntime(27472): at android.os.HandlerThread.run(HandlerThread.java:60)
01-17 21:14:44.560: D/dalvikvm(27472): GC_CONCURRENT freed 3520K, 16% free 22535K/26695K, paused 14ms+24ms, total 131ms

支持库是最新的:-

enter image description here

最佳答案

setColor() is new to API Level 21并且不适用于旧设备。

强烈建议您切换到NotificationCompat.Builder,因为它将允许您调用setColor() 并且会简单地跳过它在旧设备上工作。

关于android - java.lang.NoSuchMethodError : android. 应用程序通知$Builder.setColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28001194/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com