开发者

question about opening a new activity from notification from current activity

开发者 https://www.devze.com 2023-03-28 12:02 出处:网络
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 clickin

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号