这是我的代码,我正在尝试将所有记录保存在JSON文件中,但我最终只得到了最后一条记录。谢谢!
public class Moduletest extends ActivityInstrumentationTestCase2<Your Activity>{
protected void setUp(){
super.setUp();
ActivityLifecycleMonitorRegistry.getInstance().addLifecycleCallback(new ActivityLifecycleCallback() {
@Override public void onActivityLifecycleChanged(Activity activity, Stage stage) {
if (stage == Stage.PRE_ON_CREATE) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
});
}
}
答案 0 :(得分:0)
这解决了我的问题
try {
$output = $web_service->query($input);
if($output['HTTP_OK'] == true) {
print_r($output['DATA']);
foreach (json_decode($output['DATA']) as $obj) {
print_r($obj);
}
}
file_put_contents("data.json", $output['DATA']);