问题
How do I use onNewIntent inside a ListView activity? Actually I am displaying a ListView, while displaying I got an event or status from the server side and then I need to make some changes inside the currently displaying ListView(e.g here the ListView is a contact list and based on event I want to change the text color of particular items as online/offline status).
So my point is, is there any way to get the status inside the ListView activity or ArrayAdapter so that I can make the changes whatever is required as my previous intent is already running I dont want to make any changes in that, does onNewIntent allow me to do the same that I'm looking for?
回答1:
Mark your activity as android:launchMode="singleTop" in AndroidManifest.xml and then override onNewIntent() to capture new intents. Afterwards, perform your changes in list's data and finally call yourAdapter.notifyDataSetChanged() to apply changes.
来源:https://stackoverflow.com/questions/8500636/how-to-use-onnewintent-while-displaying-list-view