を行ったようにあなたのコードは動作しますAPI呼び出しを行います。応答は、現在のHTML文書であり、それをWebブラウザ(同じ内容がOkHttpClient
インスタンスで両方のWebブラウザとロギングのために行く)を見た場合にそれが混乱を作る:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing Connection Page</title>
</head>
<body>
{"all":[{"id":"0","Country":"Brazil","Language":"Portuguese","Topic":"HandWashing","Title":"How to Wash Your Hands","Video":"AKA1_Fante_Ghana_HandWashing_Final.3gp","Videolight":"AKA1_Fante_Ghana_HandWashing_Final_Light.3gp","Description":"Washing hands is the best way to prevent the spread of germs and diseases. Dirty hands can carry pathogenic germs that can sicken a person or spread diseases to others. Microorganisms such as bacteria, viruses, parasites, fungi and various chemicals can enter our bodies directly when we touch our face, eyes, nose or mouth or may enter indirectly, when our dirty hands stain surfaces touched by others or where food is prepared. The habit of washing hands with soap and water constitutes the first line of defense against the spread of many diseases, from the common cold or diarrhea to more serious illnesses such as meningitis, influenza or hepatitis as well as many other diseases. This 2-D animation describes the importance of hand washing.","Image":"HandWashing.jpg"},{"id":"1","Country":"Kenya","Language":"Swahili","Topic":"SGComposting3D","Title":"Survival Gardening: How to Create Compost (3D)","Video":"SW_Swahili_Kenya_SGComposting3D_Final.3gp","Videolight":"SW_Swahili_Kenya_SGComposting3D_Final_Light.3gp","Description":"Compost can be used to improve the quality of your soil. You can use plant materials, animal manure and kitchen scraps to create compost. Compost will add nutrients and organic matter to your soil. This animation explains the process of creating and storing compost.","Image":"SGComposting3D.jpg"}],"Language":["Portuguese","Swahili"],"Topic":["HandWashing","SGComposting3D"],"Country":["Brazil","Kenya"]}
</body>
</html>
をあなただけmobileApp.php
を修正する必要がありますスクリプトを作成し、JSON構造に関係しないすべてのコンテンツを削除します。応答Content-Type
ヘッダがJSON MIMEタイプ:What is the correct JSON content type?に設定されているといいでしょう。
どのようにjsonを解析しようとしていますか?このようにconverter-gsonを使用してコード – AwaisMajeed
を共有します: 'Retrofit retrofit = new Retrofit.Builder() .baseUrl(" http://sawbo-illinois.org ") .addConverterFactory(GsonConverterFactory.create()) .build ); ServiceAPIサービス= retrofit.create(ServiceAPI.class); final call
これは?これはどこですか? – AwaisMajeed