私のデータベースにトークンを送信しようとしています。しかし、私のデータベースはトークンを受け取っていません。私は最終的なOkHttpClientクライアント=新しいOkHttpClient()がスレッドの問題を抱えていることを知りました。これを修正するには?私は最新のokhttp3とokio jarファイルを使用しています。最終的なOkHttpClientクライアントでのマルチスレッドの問題=新しいOkHttpClient();
MyfirebaseInstanceIDService.java
package ******;
import android.util.Log;
import android.widget.Toast;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import java.io.IOException;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG =
MyFirebaseInstanceIDService.class.getSimpleName();
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String token = FirebaseInstanceId.getInstance().getToken();
sendToken(token);
}
private void sendToken(String token) {
final OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("token",token)
.build();
final okhttp3.Request request = new okhttp3.Request.Builder()
.url("******")
.post(body)
.build();
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
スタックトレース
01-26 05:16:09.564: W/GLSUser(2025): [AppCertManager] IOException while
キー要求: 1月26日05:16:09.564:GLSUser/W(2025):にjava.io.IOException:無効なデバイスキー の応答。 1月26日05:16:09.564:W/GLSUser(2025):16:09.564:
eka.a(:com.google.android.gms:271)
01-26 05:16:09.564: W/GLSUser(2025):
eka.a(:com.google.android.gms:4236)
01-26 05:16:09.564: W/GLSUser(2025): at ejz.a(:com.google.android.gms:46)
01-26 05:16:09.564: W/GLSUser(2025): at ejt.a(:com.google.android.gms:53)
01-26 05:16:09.564: W/GLSUser(2025): at ejs.a(:com.google.android.gms:111)
01-26 05:16:09.564: W/GLSUser(2025):at com.google.android.gms.auth.account.be.
legacy.AuthCronChimeraService.b
(:com.google.android.gms:4052)
01-26 05:16:09.564: W/GLSUser(2025):atdup.call(:com.google.android.gms:2043)
01-26 05:16:09.564: W/GLSUser(2025):a
java.util.concurrent.FutureTask.run(FutureTask.java:237)
1月26日05時(2025)GLSUser/W:kmo.runで(:com.google .android.gms:450) 01-26 05:16:09.564:W/GLSUser(2025):java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 01-26 05:16:09.564 GLSUser(2025):kqt.run(:):W/GLSUser(2025):java.util.concurrent.ThreadPoolExecutorで$ Worker.run(ThreadPoolExecutor.java:607) 01-26 05:16:09.564: com// GLSUser(2025):java.lang.Thread.run(Thread.java:761) 01-26 05:16:01-26 05:16:09.564: 09.572:W/ContentTaskController(2025):Invali d newTaskは開始トラックに
が提供されました。