androidintentservice

How to update recyclerview using Intentservice without data duplicate


I have a recyclerview getting data with http request using Intentservice. I have a button to update my recylcerview adapter. When i push this button data updates and it's seems alright. But when i push this button and change screen orientation, number of rows in recylcler view doubles.

I have this in my manefest:

        <activity android:name=".MainActivity"
        android:configChanges="orientation|screenSize">

So seems like android shouldn't create a new activity with changing orientation and he doesn't when i just change orientation without pushing update button. Anyone got some ideas about that? Thanks.


Solution

  • Just clear the list before adding the data for first time. so that it will also help you while coming back on the same page.