为什么改造会设置先前对重新加载数据的响应?
why retrofit is setting previous response on reloading data?
我正在开发一个为练习或考试提供问题集的应用程序,在测试结束时,我们提供一个重新测试你的技能的应用程序,但每当用户刷新重新测试时,它都会显示与第一次尝试相同的响应,但如果我尝试从 phpfile url 中获取数据,它会显示不同的数据集
只是想知道是否有任何缓存与此有关。
由于限制,请忽略这些 URL 所有这些都已编辑
连接文件
RestAdapter.Builder builder=new RestAdapter.Builder();
builder.setEndpoint("xyz.com/Android/");
builder.setLogLevel(RestAdapter.LogLevel.FULL);
builder.setClient(new OkClient(new OkHttpClient()));
RestAdapter adapter=builder.build();
return(adapter.create(SetDataToDatabase.class));
@GET("/phpFile.php")
void abc(@Query("sub") String subject, Callback<BeanFile> testQuestion_beanCallback);
请求数据的方法
con.abc(subject, new Callback<BeanFile>() {
@Override
public void success(BeanFile bean, Response response) {
adapter = new TestPaperAdapter(bean.data, Test.this, id, answers, attempt, choosedAnswer);
recyclerView.setAdapter(adapter);
}
@Override
public void failure(RetrofitError error) {
if (error.getKind().equals(RetrofitError.Kind.NETWORK)) {
Toast.makeText(Test.this, "No Internet connection found.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Test.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}
});
Logcat
--------- beginning of system
2020-08-27 19:44:21.494 2172-3954/system_process I/ActivityTaskManager: START u0 {cmp=com.Prince.xyz/.Test (has extras)} from uid 10137
2020-08-27 19:44:21.514 1846-8173/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24186159 , only wrote 24185990
2020-08-27 19:44:21.561 2172-3954/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:21.577 2172-3954/system_process I/chatty: uid=1000(system) Binder:2172_12 identical 48 lines
2020-08-27 19:44:21.577 2172-3954/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:21.584 14105-14105/com.Prince.xyz W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@cc389ba
2020-08-27 19:44:22.401 14105-14543/com.Prince.xyz D/Retrofit: ---> HTTP GET xyz.com/Android/phpFile.php?sub=mix
2020-08-27 19:44:22.401 14105-14543/com.Prince.xyz D/Retrofit: ---> END HTTP (no body)
2020-08-27 19:44:22.446 1839-14546/? E/ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
2020-08-27 19:44:22.480 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2965504
2020-08-27 19:44:22.655 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/ConscryptFileDescriptorSocket;->setUseSessionTickets(Z)V (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.655 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/ConscryptFileDescriptorSocket;->setHostname(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.655 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.705 14105-14105/com.Prince.xyz E/RecyclerView: No adapter attached; skipping layout
2020-08-27 19:44:22.712 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 17051648
2020-08-27 19:44:22.741 14105-14119/com.Prince.xyz I/e.xyz: Background young concurrent copying GC freed 12549(896KB) AllocSpace objects, 11(1260KB) LOS objects, 9% free, 7645KB/8484KB, paused 2.509ms total 116.491ms
2020-08-27 19:44:22.835 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.856 2172-2208/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:22.859 2172-2208/system_process I/chatty: uid=1000(system) android.anim identical 18 lines
2020-08-27 19:44:22.859 2172-2208/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:22.934 14105-14502/com.Prince.xyz D/FA: Connected to remote service
2020-08-27 19:44:23.101 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 7200(409KB) AllocSpace objects, 8(4688KB) LOS objects, 33% free, 12MB/18MB, paused 1.298ms total 290.209ms
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: <--- HTTP 200 xyz.com/Android/phpFile.php?sub=mix (838ms)
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: OkHttp-Selected-Protocol: h2
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: date: Thu, 27 Aug 2020 14:14:26 GMT
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: server: nginx/1.17.6
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: content-type: text/html; charset=UTF-8
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: vary: Accept-Encoding
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: x-server-cache: true
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: x-proxy-cache: HIT
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: OkHttp-Sent-Millis: 1598537662989
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: OkHttp-Received-Millis: 1598537663224
2020-08-27 19:44:23.249 14105-14543/com.Prince.xyz D/Retrofit: {"result":true,"data":[{"0":"432","quesId":"432","1":"Which animal is said to have fingerprints almost identical from those of human beings?","question":"Which animal is said to have fingerprints almost identical from those of human beings?","2":"Panda","optA":"Panda","3":"Raccoon","optB":"Raccoon","4":"Koala","optC":"Koala","5":"Lemur","optD":"Lemur","6":"C","answer":"C","7":"Fingerprint Examination","subject":"Fingerprint Examination"}]}
2020-08-27 19:44:23.250 14105-14543/com.Prince.xyz D/Retrofit: <--- END HTTP (4482-byte body)
2020-08-27 19:44:23.353 14105-14105/com.Prince.xyz D/Tag: 12
2020-08-27 19:44:23.370 2446-12529/com.google.android.gms.persistent E/SQLiteDatabase: Error inserting flex_time=1400000 job_id=-1 period=2801000 source=16 requires_charging=0 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 source_version=200414000 required_network_type=0 runtime=1598537663267 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
at aozt.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):147)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):182)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):25)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):177)
at aovr.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):8)
at srw.b(:com.google.android.gms@200414022@20.04.14 (040700-294335909):14)
at srw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at sxw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):0)
at java.lang.Thread.run(Thread.java:919)
2020-08-27 19:44:23.381 2172-3954/system_process E/InputDispatcher: Window handle Window{d62a60f u0 com.Prince.xyz/com.Prince.xyz.Test} has no registered input channel
2020-08-27 19:44:23.509 2446-12529/com.google.android.gms.persistent E/SQLiteDatabase: Error inserting flex_time=1399000 job_id=-1 period=2800000 source=16 requires_charging=0 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 source_version=200414000 required_network_type=0 runtime=1598537663420 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
at aozt.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):147)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):182)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):25)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):177)
at aovr.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):8)
at srw.b(:com.google.android.gms@200414022@20.04.14 (040700-294335909):14)
at srw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at sxw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):0)
at java.lang.Thread.run(Thread.java:919)
2020-08-27 19:44:23.657 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 17051648
2020-08-27 19:44:23.811 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 17051648
2020-08-27 19:44:24.061 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 2128(114KB) AllocSpace objects, 15(7912KB) LOS objects, 35% free, 11MB/17MB, paused 876us total 104.785ms
2020-08-27 19:44:24.647 1846-2019/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24460726 , only wrote 24324139
2020-08-27 19:44:26.193 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 1151(74KB) AllocSpace objects, 14(6832KB) LOS objects, 35% free, 11MB/17MB, paused 701us total 103.154ms
2020-08-27 19:44:29.757 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 1157(77KB) AllocSpace objects, 17(7680KB) LOS objects, 35% free, 11MB/17MB, paused 695us total 116.937ms
2020-08-27 19:44:31.912 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 1163(81KB) AllocSpace objects, 19(9032KB) LOS objects, 35% free, 11MB/17MB, paused 716us total 120.237ms
2020-08-27 19:44:32.201 1846-8173/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24324181 , only wrote 24324139
2020-08-27 19:44:32.220 14105-14550/com.Prince.xyz D/Retrofit: ---> HTTP GET xyz.com/Android/phpFile.php?sub=mix
2020-08-27 19:44:32.220 14105-14550/com.Prince.xyz D/Retrofit: ---> END HTTP (no body)
2020-08-27 19:44:32.224 1839-14551/? E/ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
2020-08-27 19:44:32.525 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2965504
2020-08-27 19:44:33.059 14105-14550/com.Prince.xyz D/Retrofit: <--- HTTP 200 xyz.com/Android/phpFile.php?sub=mix (838ms)
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: OkHttp-Selected-Protocol: h2
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: date: Thu, 27 Aug 2020 14:14:35 GMT
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: server: nginx/1.17.6
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: content-type: text/html; charset=UTF-8
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: vary: Accept-Encoding
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: x-server-cache: true
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: x-proxy-cache: HIT
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: OkHttp-Sent-Millis: 1598537672799
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: OkHttp-Received-Millis: 1598537673057
2020-08-27 19:44:33.066 14105-14550/com.Prince.xyz D/Retrofit: {"result":true,"data":[{"0":"432","quesId":"432","1":"Which animal is said to have fingerprints almost identical from those of human beings?","question":"Which animal is said to have fingerprints almost identical from those of human beings?","2":"Panda","optA":"Panda","3":"Raccoon","optB":"Raccoon","4":"Koala","optC":"Koala","5":"Lemur","optD":"Lemur","6":"C","answer":"C","7":"Fingerprint Examination","subject":"Fingerprint Examination"}]}
2020-08-27 19:44:33.067 14105-14550/com.Prince.xyz D/Retrofit: <--- END HTTP (4482-byte body)
2020-08-27 19:44:33.077 14105-14105/com.Prince.xyz D/Tag: 12
2020-08-27 19:44:33.098 2172-3027/system_process E/InputDispatcher: Window handle Window{500f57e u0 com.Prince.xyz/com.Prince.xyz.Test} has no registered input channel
2020-08-27 19:44:33.114 2172-3954/system_process E/InputDispatcher: Window handle Window{500f57e u0 com.Prince.xyz/com.Prince.xyz.Test} has no registered input channel
2020-08-27 19:44:33.392 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 6277(388KB) AllocSpace objects, 14(6832KB) LOS objects, 34% free, 11MB/17MB, paused 8.099ms total 299.390ms
2020-08-27 19:44:35.366 1846-2019/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24601375 , only wrote 24463610
2020-08-27 19:44:38.524 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 912(97KB) AllocSpace objects, 13(6560KB) LOS objects, 34% free, 11MB/17MB, paused 714us total 109.312ms
2020-08-27 19:44:42.746 1846-8173/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24463641 , only wrote 24463610
我在回答我自己的问题
我刚刚找到了一个临时解决方案,但未能找到改造内部发生的事情,android 以及原因
@GET("/phpFile.php")
void abc(@Query("sub") String subject,@Quesry("aaaa") int x, Callback<BeanFile> testQuestion_beanCallback);
并且在 PHP 文件中我收到了任何变量但未使用它
Random rand = new Random();
int n = 0;
n = rand.nextInt(anyValue);
con.abc(subject,n, new Callback<BeanFile>() {
@Override
public void success(BeanFile bean, Response response) {
adapter = new TestPaperAdapter(bean.data, Test.this, id, answers, attempt, choosedAnswer);
recyclerView.setAdapter(adapter);
}
@Override
public void failure(RetrofitError error) {
if (error.getKind().equals(RetrofitError.Kind.NETWORK)) {
Toast.makeText(Test.this, "No Internet connection found.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Test.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}
});
您可以按照这些文档从 OkHttp 调试缓存
事件 - https://square.github.io/okhttp/events/
缓存说明 - https://square.github.io/okhttp/caching/
您可以像使用假参数一样覆盖缓存,或者通过专门覆盖行为
https://square.github.io/okhttp/4.x/okhttp/okhttp3/-cache/
Request request = new Request.Builder()
.cacheControl(new CacheControl.Builder().noCache().build())
.url("http://publicobject.com/helloworld.txt")
.build();
我正在开发一个为练习或考试提供问题集的应用程序,在测试结束时,我们提供一个重新测试你的技能的应用程序,但每当用户刷新重新测试时,它都会显示与第一次尝试相同的响应,但如果我尝试从 phpfile url 中获取数据,它会显示不同的数据集
只是想知道是否有任何缓存与此有关。
由于限制,请忽略这些 URL 所有这些都已编辑
连接文件
RestAdapter.Builder builder=new RestAdapter.Builder();
builder.setEndpoint("xyz.com/Android/");
builder.setLogLevel(RestAdapter.LogLevel.FULL);
builder.setClient(new OkClient(new OkHttpClient()));
RestAdapter adapter=builder.build();
return(adapter.create(SetDataToDatabase.class));
@GET("/phpFile.php")
void abc(@Query("sub") String subject, Callback<BeanFile> testQuestion_beanCallback);
请求数据的方法
con.abc(subject, new Callback<BeanFile>() {
@Override
public void success(BeanFile bean, Response response) {
adapter = new TestPaperAdapter(bean.data, Test.this, id, answers, attempt, choosedAnswer);
recyclerView.setAdapter(adapter);
}
@Override
public void failure(RetrofitError error) {
if (error.getKind().equals(RetrofitError.Kind.NETWORK)) {
Toast.makeText(Test.this, "No Internet connection found.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Test.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}
});
Logcat
--------- beginning of system
2020-08-27 19:44:21.494 2172-3954/system_process I/ActivityTaskManager: START u0 {cmp=com.Prince.xyz/.Test (has extras)} from uid 10137
2020-08-27 19:44:21.514 1846-8173/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24186159 , only wrote 24185990
2020-08-27 19:44:21.561 2172-3954/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:21.577 2172-3954/system_process I/chatty: uid=1000(system) Binder:2172_12 identical 48 lines
2020-08-27 19:44:21.577 2172-3954/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:21.584 14105-14105/com.Prince.xyz W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@cc389ba
2020-08-27 19:44:22.401 14105-14543/com.Prince.xyz D/Retrofit: ---> HTTP GET xyz.com/Android/phpFile.php?sub=mix
2020-08-27 19:44:22.401 14105-14543/com.Prince.xyz D/Retrofit: ---> END HTTP (no body)
2020-08-27 19:44:22.446 1839-14546/? E/ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
2020-08-27 19:44:22.480 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2965504
2020-08-27 19:44:22.655 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/ConscryptFileDescriptorSocket;->setUseSessionTickets(Z)V (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.655 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/ConscryptFileDescriptorSocket;->setHostname(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.655 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.705 14105-14105/com.Prince.xyz E/RecyclerView: No adapter attached; skipping layout
2020-08-27 19:44:22.712 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 17051648
2020-08-27 19:44:22.741 14105-14119/com.Prince.xyz I/e.xyz: Background young concurrent copying GC freed 12549(896KB) AllocSpace objects, 11(1260KB) LOS objects, 9% free, 7645KB/8484KB, paused 2.509ms total 116.491ms
2020-08-27 19:44:22.835 14105-14543/com.Prince.xyz W/e.xyz: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (greylist,core-platform-api, reflection, allowed)
2020-08-27 19:44:22.856 2172-2208/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:22.859 2172-2208/system_process I/chatty: uid=1000(system) android.anim identical 18 lines
2020-08-27 19:44:22.859 2172-2208/system_process W/InputReader: Device has associated, but no associated display id.
2020-08-27 19:44:22.934 14105-14502/com.Prince.xyz D/FA: Connected to remote service
2020-08-27 19:44:23.101 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 7200(409KB) AllocSpace objects, 8(4688KB) LOS objects, 33% free, 12MB/18MB, paused 1.298ms total 290.209ms
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: <--- HTTP 200 xyz.com/Android/phpFile.php?sub=mix (838ms)
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: OkHttp-Selected-Protocol: h2
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: date: Thu, 27 Aug 2020 14:14:26 GMT
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: server: nginx/1.17.6
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: content-type: text/html; charset=UTF-8
2020-08-27 19:44:23.240 14105-14543/com.Prince.xyz D/Retrofit: vary: Accept-Encoding
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: x-server-cache: true
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: x-proxy-cache: HIT
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: OkHttp-Sent-Millis: 1598537662989
2020-08-27 19:44:23.241 14105-14543/com.Prince.xyz D/Retrofit: OkHttp-Received-Millis: 1598537663224
2020-08-27 19:44:23.249 14105-14543/com.Prince.xyz D/Retrofit: {"result":true,"data":[{"0":"432","quesId":"432","1":"Which animal is said to have fingerprints almost identical from those of human beings?","question":"Which animal is said to have fingerprints almost identical from those of human beings?","2":"Panda","optA":"Panda","3":"Raccoon","optB":"Raccoon","4":"Koala","optC":"Koala","5":"Lemur","optD":"Lemur","6":"C","answer":"C","7":"Fingerprint Examination","subject":"Fingerprint Examination"}]}
2020-08-27 19:44:23.250 14105-14543/com.Prince.xyz D/Retrofit: <--- END HTTP (4482-byte body)
2020-08-27 19:44:23.353 14105-14105/com.Prince.xyz D/Tag: 12
2020-08-27 19:44:23.370 2446-12529/com.google.android.gms.persistent E/SQLiteDatabase: Error inserting flex_time=1400000 job_id=-1 period=2801000 source=16 requires_charging=0 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 source_version=200414000 required_network_type=0 runtime=1598537663267 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
at aozt.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):147)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):182)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):25)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):177)
at aovr.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):8)
at srw.b(:com.google.android.gms@200414022@20.04.14 (040700-294335909):14)
at srw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at sxw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):0)
at java.lang.Thread.run(Thread.java:919)
2020-08-27 19:44:23.381 2172-3954/system_process E/InputDispatcher: Window handle Window{d62a60f u0 com.Prince.xyz/com.Prince.xyz.Test} has no registered input channel
2020-08-27 19:44:23.509 2446-12529/com.google.android.gms.persistent E/SQLiteDatabase: Error inserting flex_time=1399000 job_id=-1 period=2800000 source=16 requires_charging=0 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 source_version=200414000 required_network_type=0 runtime=1598537663420 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
at aozt.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):147)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):182)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):25)
at aozi.a(:com.google.android.gms@200414022@20.04.14 (040700-294335909):177)
at aovr.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):8)
at srw.b(:com.google.android.gms@200414022@20.04.14 (040700-294335909):14)
at srw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at sxw.run(:com.google.android.gms@200414022@20.04.14 (040700-294335909):0)
at java.lang.Thread.run(Thread.java:919)
2020-08-27 19:44:23.657 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 17051648
2020-08-27 19:44:23.811 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 17051648
2020-08-27 19:44:24.061 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 2128(114KB) AllocSpace objects, 15(7912KB) LOS objects, 35% free, 11MB/17MB, paused 876us total 104.785ms
2020-08-27 19:44:24.647 1846-2019/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24460726 , only wrote 24324139
2020-08-27 19:44:26.193 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 1151(74KB) AllocSpace objects, 14(6832KB) LOS objects, 35% free, 11MB/17MB, paused 701us total 103.154ms
2020-08-27 19:44:29.757 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 1157(77KB) AllocSpace objects, 17(7680KB) LOS objects, 35% free, 11MB/17MB, paused 695us total 116.937ms
2020-08-27 19:44:31.912 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 1163(81KB) AllocSpace objects, 19(9032KB) LOS objects, 35% free, 11MB/17MB, paused 716us total 120.237ms
2020-08-27 19:44:32.201 1846-8173/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24324181 , only wrote 24324139
2020-08-27 19:44:32.220 14105-14550/com.Prince.xyz D/Retrofit: ---> HTTP GET xyz.com/Android/phpFile.php?sub=mix
2020-08-27 19:44:32.220 14105-14550/com.Prince.xyz D/Retrofit: ---> END HTTP (no body)
2020-08-27 19:44:32.224 1839-14551/? E/ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
2020-08-27 19:44:32.525 1856-1972/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2965504
2020-08-27 19:44:33.059 14105-14550/com.Prince.xyz D/Retrofit: <--- HTTP 200 xyz.com/Android/phpFile.php?sub=mix (838ms)
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: OkHttp-Selected-Protocol: h2
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: date: Thu, 27 Aug 2020 14:14:35 GMT
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: server: nginx/1.17.6
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: content-type: text/html; charset=UTF-8
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: vary: Accept-Encoding
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: x-server-cache: true
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: x-proxy-cache: HIT
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: OkHttp-Sent-Millis: 1598537672799
2020-08-27 19:44:33.060 14105-14550/com.Prince.xyz D/Retrofit: OkHttp-Received-Millis: 1598537673057
2020-08-27 19:44:33.066 14105-14550/com.Prince.xyz D/Retrofit: {"result":true,"data":[{"0":"432","quesId":"432","1":"Which animal is said to have fingerprints almost identical from those of human beings?","question":"Which animal is said to have fingerprints almost identical from those of human beings?","2":"Panda","optA":"Panda","3":"Raccoon","optB":"Raccoon","4":"Koala","optC":"Koala","5":"Lemur","optD":"Lemur","6":"C","answer":"C","7":"Fingerprint Examination","subject":"Fingerprint Examination"}]}
2020-08-27 19:44:33.067 14105-14550/com.Prince.xyz D/Retrofit: <--- END HTTP (4482-byte body)
2020-08-27 19:44:33.077 14105-14105/com.Prince.xyz D/Tag: 12
2020-08-27 19:44:33.098 2172-3027/system_process E/InputDispatcher: Window handle Window{500f57e u0 com.Prince.xyz/com.Prince.xyz.Test} has no registered input channel
2020-08-27 19:44:33.114 2172-3954/system_process E/InputDispatcher: Window handle Window{500f57e u0 com.Prince.xyz/com.Prince.xyz.Test} has no registered input channel
2020-08-27 19:44:33.392 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 6277(388KB) AllocSpace objects, 14(6832KB) LOS objects, 34% free, 11MB/17MB, paused 8.099ms total 299.390ms
2020-08-27 19:44:35.366 1846-2019/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24601375 , only wrote 24463610
2020-08-27 19:44:38.524 14105-14119/com.Prince.xyz I/e.xyz: Background concurrent copying GC freed 912(97KB) AllocSpace objects, 13(6560KB) LOS objects, 34% free, 11MB/17MB, paused 714us total 109.312ms
2020-08-27 19:44:42.746 1846-8173/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 24463641 , only wrote 24463610
我在回答我自己的问题
我刚刚找到了一个临时解决方案,但未能找到改造内部发生的事情,android 以及原因
@GET("/phpFile.php")
void abc(@Query("sub") String subject,@Quesry("aaaa") int x, Callback<BeanFile> testQuestion_beanCallback);
并且在 PHP 文件中我收到了任何变量但未使用它
Random rand = new Random();
int n = 0;
n = rand.nextInt(anyValue);
con.abc(subject,n, new Callback<BeanFile>() {
@Override
public void success(BeanFile bean, Response response) {
adapter = new TestPaperAdapter(bean.data, Test.this, id, answers, attempt, choosedAnswer);
recyclerView.setAdapter(adapter);
}
@Override
public void failure(RetrofitError error) {
if (error.getKind().equals(RetrofitError.Kind.NETWORK)) {
Toast.makeText(Test.this, "No Internet connection found.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Test.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}
});
您可以按照这些文档从 OkHttp 调试缓存
事件 - https://square.github.io/okhttp/events/
缓存说明 - https://square.github.io/okhttp/caching/
您可以像使用假参数一样覆盖缓存,或者通过专门覆盖行为
https://square.github.io/okhttp/4.x/okhttp/okhttp3/-cache/
Request request = new Request.Builder()
.cacheControl(new CacheControl.Builder().noCache().build())
.url("http://publicobject.com/helloworld.txt")
.build();