Android - When launch the same activity from widget with different extras, how to prevent the same instance show up after returned from HOME button?

前端 未结 5 1828
我在风中等你
我在风中等你 2021-01-13 12:52

I have a widget that contains 4 buttons to show 4 stock prices, each of them will launch into the same activity Quote.class to show stock details. In onUpdate(), it will set

5条回答
  •  生来不讨喜
    2021-01-13 13:31

    • It is normal for onDestroy to possibly not get called if you do simple task switching (like holding the HOME button). If you need to do clean-up, it needs to go in onPause.
    • I believe the problem is that you have a PendingIntent that only differs by extra. PendingIntents are cached, so if you use two with the same action and data, they'll overwrite each other. You can circumvent that by giving each some random data. Try passing the symbol in the data rather than through the extra (which is preferred anyway).

提交回复
热议问题