question about opening a new activity from notification from current activity
My current activity is MyActivity( used to display the data on the 开发者_如何转开发list ) and I am getting a new notification. What I am expecting is the data on the list will be refresh when clicking on the notification but It does work that way....There is also a picture of a issue. Any ideas are welcome. Thanks
if your problem is ...
clicking the notification opens a new activity every time them you have to set the activity launchMode as below
<activity android:name=".MyActivity" android:launchMode="singleTop">
<meta-data ...
</activity>
and handle the notification intent as below
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handleIntent(getIntent())
}
...
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(getIntent())
}
...
private void handleIntent(Intent intent) {
//Refresh your list here.
}
use listAdapter.notifyDataSetChanged(); onResume function of Activity, so when you come again on activity, your List show you updated data.
精彩评论