2016-05-04 8 views
5

मैंने एंड्रॉइड 6.0 को अपग्रेड किया और मेरे ऐप में समस्या है।पृष्ठभूमि रंग सफेद होने पर एंड्रॉइड अधिसूचना आइकन रंग बदला नहीं जाता है

जब स्टेटस बार पृष्ठभूमि रंग सफेद नहीं है, अधिसूचना आइकन अच्छा है। (अधिसूचना आइकन पीएनजी में केवल सफेद और अल्फा है)

लेकिन यदि कुछ ऐप्स पृष्ठभूमि रंग को सफेद में बदलते हैं, तो मेरा अधिसूचना आइकन काला में उलटा नहीं है।

स्थिति बार पृष्ठभूमि रंग अन्य ऐप द्वारा सफेद सेट करते समय मैं सफेद अधिसूचना आइकन को काला में कैसे बदल सकता हूं? (मैं यह नहीं कह रहा हूं कि मैं रंग आइकन का उपयोग कैसे कर सकता हूं।)

छवि के नीचे एक समस्या दिखाती है।

normal status

when changed background color to white, my icon is not changed to black only

  • अधिसूचना निर्माण कोड

    Notification.Builder mBuilder = 
         new Notification.Builder(context) 
           .setSmallIcon(R.drawable.ic_notifications_none) 
           .setPriority(priority2) 
           .setOngoing(true); 
    
    mBuilder.setContent(generateMessageView(message)); 
    
    Intent notificationIntent = new Intent(context, MainActivity.class); 
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP 
              | Intent.FLAG_ACTIVITY_SINGLE_TOP); 
    
    PendingIntent intent = PendingIntent.getActivity(context, 0, 
         notificationIntent, 0); 
    NotificationManager mNotificationManager = 
         (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
    mBuilder.setContentIntent(intent); 
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); 
    
  • मान-v23/styles.xml

    <style name="AppTheme" parent="android:Theme.Material.NoActionBar">    
    </style> 
    

** मिले एक समाधान **

मैं drawable निर्देशिका के लिए सूचना आइकन जोड़ा drawable- नहीं * डीपीआई। अब यह काम कर रहा है।

+0

चेक बाहर इस [पोस्ट] (सूचना आइकन सेट http://stackoverflow.com/questions/28387602/notification-bar-icon-turns-white- इन-एंड्रॉयड-5-लॉलीपॉप)। यह भी पढ़ें [प्रलेखन] (http://developer.android.com/reference/android/app/Notification.Builder.html#setColor%28int%29)। उम्मीद है कि आप एक सुराग प्राप्त कर सकते हैं। चीयर्स ....:) – verbose

+0

@verbose मैं पहले ही पढ़ चुका हूं लेकिन फिर से जांच करूंगा। धन्यवाद –

+0

मैंने आपके समाधान की कोशिश की और यह मेरे लिए काम नहीं किया। –

उत्तर

0

मुझे लगता है कि समस्या डिवाइस एंड्रॉइड 5.0 या उच्चतर में है।

Notification notification = new Notification.Builder(context) 
     .setAutoCancel(true) 
     .setContentTitle("My notification") 
     .setContentText("Look, white in Lollipop, else color!") 
     .setSmallIcon(getNotificationIcon()) 
     .build(); 

return notification; 

और विधि getNotificationIcon():

https://developer.android.com/design/patterns/notifications.html
https://developer.android.com/about/versions/android-5.0-changes.html

यहाँ एक समाधान है

private int getNotificationIcon() { 
    boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP); 
    return useWhiteIcon ? R.drawable.icon_black : R.drawable.ic_nomarl; 
} 
+0

धन्यवाद लेकिन यह काम नहीं कर रहा है। मुझे एंड्रॉइड नमूना से एलएनोटिफिकेशन मिले और इसमें काले आइकन छवि नहीं है, लेकिन सफेद ऐप काला (गहरा भूरा) है जब अन्य ऐप सफेद स्टेटस बार के साथ चल रहा है। और मुझे LNotifications से कोई विशेष कोड प्रकार बदलने का रंग नहीं मिला। –

2

मैं अपने जवाब देने के लिए देर हो चुकी है, लेकिन दूसरों को, जो एक ही समस्या है के लिए ,

मुझे यह समस्या भी थी और मैंने पाया कि समस्या ग्राफिकल आइकन के साथ है। आप इस ऑनलाइन उपकरण का उपयोग कर समस्या का समाधान कर सकते हैं। इस लिंक को खोलने:

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_stat_call_white

तो अपनी छवि चुनने (बड़े आयाम के साथ), तो संसाधन डाउनलोड करने और उन्हें अपनी परियोजना के लिए नकल।

तो का उपयोग कर .setSmallIcon(R.drawable.ICON_NEW_NAME)

आशा है कि यह मदद

+0

धन्यवाद, यह मेरी समस्या हल हो गया – Oblivionkey3

संबंधित मुद्दे