简体   繁体   English

重新创建活动时,Android Volley不会从服务器加载数据

[英]Android Volley does not load data from server when recreating an Activity

I have three Activities, namely A, B and C. 我有三个活动,即A,B和C。

Activities A and C are FragmentActivities 活动A和C是FragmentActivities

Finishing from Activity B is fine, since Volley will work properly in Activity A. 由于Volley将在活动A中正常工作,因此完成活动B很好。

Same thing when finishing Activity C. 完成活动C时也是一样。

However, when I want to go from Activity C to A, I have to destroy B. It worked, but the problem is, I received no data from Volley when loading to Activity A. 但是,当我想从活动C转到A时,我必须销毁B。它确实起作用,但是问题是,当加载到活动A时,我没有从Volley收到任何数据。

Add these flags when starting activity A 开始活动A时添加这些标志

    Intent intent = new Intent(this, ActivityA.class)
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

and add flag in manifest also 并在清单中添加标志

    android:launchMode="singleTask"

you will be getting new callback onNewIntent(Intent intent) if you want to send any data 如果您想发送任何数据,您将在newIntent(Intent intent)上获得新的回调

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM