Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NotificationCompat only shows white screen on Lollipop  RSS feed

 
dev goku
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to show notification using NotificationCompat but i only get white screen,this is my code.

 
Pete Letkeman
Ranch Foreman
Posts: 612
16
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few follow up questions if I may:
  • Are you trying this in the Android emulator or on a actual physical device?  If on a physical device then which one(s)?
  • What is the result if you try this using the Android emulator, but different versions such as Android 4.4.x, Android 6.0.x and Android 7.0.x?
  • Which version of Android are you trying this on?  I know that you said Lollipop, however there are a few different versions e.g. 5.0.1, 5.0.2 and so on.
  • Are you able to post the APK somewhere so that other people can try it out on their system(s)?
  • If so then are there any unique steps that one would need to preform to duplicate that behavior/result?
  •  
    dev goku
    Greenhorn
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'm running this on a ZTE device, version Android 5.1.1,after analysing the phone settings i get to know that i have to change some Notification settings, Now i get notification on Notification bar with a white screen but not Headup notification..

    Are you able to post the APK somewhere so that other people can try it out on their system(s)?


    This is the only activity in the app..
     
    Pete Letkeman
    Ranch Foreman
    Posts: 612
    16
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What happens if you take your app as is and run it in an emulator with the same hardware settings (RAM, screen size etc) and the same Android version?

    What happens if you take your app as is and run it in an emulator  which is running a different version of Android?
     
    dev goku
    Greenhorn
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Same thing happens.
     
    Pete Letkeman
    Ranch Foreman
    Posts: 612
    16
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Interesting, but not too helpful.

    I copied your code. Put it into a new separate project running Android 5.1.1 on a Google Nexus 4 device and it works for me.
    This would lead me to believe that there is nothing wrong with your code.

    I suspect that you are not looking at the notifications bar and swiping down as shown in the screen shot.
    Yes you get a blank screen, but then again you have not provided any content for that screen yet.
    android.jpg
    [Thumbnail for android.jpg]
    Android Notification Test
     
    dev goku
    Greenhorn
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes I got like in the picture, can I get the notification without moving to activity?
     
    Pete Letkeman
    Ranch Foreman
    Posts: 612
    16
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    dev goku wrote:Yes I got like in the picture, can I get the notification without moving to activity?

    Yes, but only after you do some work. I believe that you would have to create an Android service
    https://developer.android.com/guide/components/services.html
    In that service you would have to create an event listener to trigger the notification to appear.
    The service could be as simple as a timed service to happen at lets say 3 pm or it could accept data from a REST web service and anything in between.
    The service is installed when the app is installed and I believe that there are controls in Android to enable/disable notifications for any app, even the Google supplied ones.
     
    shujat khan
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The white screen in called preview screen which android displays based on your theme until drawables and other resources are ready to be loaded in your activity.
    first apply custom theme style to your intial activity(Activity which starts first)
    like this

    android:theme="@style/Theme.MyAppTheme"

    and custom style is

    <style name="Theme" parent="android:style/Theme" />
    <style name="Theme.MyAppTheme" parent="Theme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowBackground">"COLOR YOU WANT TO PLACE WITH WHITE SCREEN"</item>
    </style>
     
    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!