小编mak*_*ung的帖子

在Android中返回null的改进响应

我想显示一个JSON值的文本.我使用Retrofit,使API呼叫我不知道如果我这样做是正确的.无论如何这是我的代码.

这是网址链接:http://api.icndb.com/jokes/random.

该网站每次都会显示一个随机笑话.以下是该网站输出的示例:

{ "type": "success", "value": { "id": 175, "joke": "When Chuck Norris was a baby, he didn't suck his mother's breast. His mother served him whiskey, straight out of the bottle.", "categories": [] } } 
Run Code Online (Sandbox Code Playgroud)

fragment.java

    String url = "http://api.icndb.com/";

    Retrofit.Builder builder = new Retrofit.Builder()
            .baseUrl(url)
            .addConverterFactory(GsonConverterFactory.create());

    Retrofit retrofit = builder.build();

    RetroFitHelper client = retrofit.create(RetroFitHelper.class);
    Call<Api> call = client.findJoke("random");

    call.enqueue(new Callback<Api>() {
        @Override
        public void onResponse(Response<Api> response, Retrofit …
Run Code Online (Sandbox Code Playgroud)

android retrofit

6
推荐指数
2
解决办法
9178
查看次数

android.app.ContextImpl.startServiceCommon上的java.lang.IllegalStateException

我在playstore上有一个应用程序,最近我只在Android 8.0设备上遇到了这些错误。请查看我从Google Play控制台收到的android stacktrace。我还包括了Firebase助手类。提前致谢 :)

java.lang.IllegalStateException: 
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1737)
  at android.app.ContextImpl.startService (ContextImpl.java:1693)
  at android.content.ContextWrapper.startService (ContextWrapper.java:650)
  at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService (Unknown Source:22)
  at com.google.firebase.iid.zzg.zzg (Unknown Source:9)
  at com.google.firebase.iid.zzg.zzb (Unknown Source:78)
  at com.google.firebase.iid.zzg.zzf (Unknown Source:2)
  at com.google.firebase.iid.FirebaseInstanceIdService.a (Unknown Source:23)
  at com.google.firebase.iid.FirebaseInstanceIdService.a (Unknown Source:34)
  at com.google.firebase.iid.FirebaseInstanceId.<init> (Unknown Source:31)
  at com.google.firebase.iid.FirebaseInstanceId.getInstance (Unknown Source:47)
  at com.google.firebase.iid.FirebaseInstanceId.getInstance (Unknown Source:4)
  at com.google.firebase.iid.FirebaseInstanceIdService.zza (Unknown Source:14)
  at com.google.firebase.iid.FirebaseInstanceIdService.handleIntent (Unknown Source:35)
  at com.google.firebase.iid.zzb$zza$1.run (Unknown Source:24)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
  at java.lang.Thread.run (Thread.java:784) 
Run Code Online (Sandbox Code Playgroud)

MyFirebaseInstanceIdService类

public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {

    private …
Run Code Online (Sandbox Code Playgroud)

java android firebase android-studio

5
推荐指数
1
解决办法
2010
查看次数

标签 统计

android ×2

android-studio ×1

firebase ×1

java ×1

retrofit ×1