How to make Android app update in execution time

前端 未结 1 842
鱼传尺愫
鱼传尺愫 2021-01-16 20:33

Hey, Im trying something in android, that has to get the words sent in sms and print on the emulator screen. But the app doesnt update in time.

I send a message. Ok.

相关标签:
1条回答
  • 2021-01-16 21:04

    You could move all most of the code in the OnCreate() to onResume within your activity. Basically you should query the content resolver within the onResume so that you get a fresh set of the data when your activity is in the foreground. Without this you are getting a snapshot when the activity is created. It's going to be paused when you go to the SMS screen and then resumed when you go back to it. It is still alive even though you switched apps so the onCreate won't be called until the activity is either killed or finished and then rentered.

    So in short move the ContentResolver.query() to the onResume. And display your state there.

    0 讨论(0)
提交回复
热议问题