微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用php文件数组连接Android微调器

如何解决用php文件数组连接Android微调器

这是一个调用以在微调器中显示数据的函数

这是我得到的回应。 响应:引起:java.lang.NullPointerException:尝试在空对象引用上调用接口方法'retrofit2.Call co.ke.smartcare.apiutilities.ApiService.fetchDocs()'

功能: 公共无效 fetchDoctors(){

<?PHP 
    $sqlactive= "SELECT * from Tabule1 WHERE TabStatus LIKE '0'";
    $result = $conn->query($sqlactive);
    if ($result->num_rows > 0) {
        while ($row = $result-> fetch_assoc()) {
            echo "<tr>
            <td>" . $row["TabKlient"] . "</td>
            <td>" . $row["TabOsoba"] . "</td>
            <td>" . $row["TabItem"] . "</td>
            <td>" . $row["TabQty"] . "</td>
            <td>" . $row["TabNote"] . "</td>
            <td>" . $row["TabAddedBy"] . "</td>
            <td>" . $row["TabDate"] . "</td>"
            '<td><a href="edit.PHP?id='.$row['ID'].'"> test </a></td>' "</tr>";
          }
    }
?>

解决方法

在这种情况下,您的改造 api 调用接口不得正确初始化。 先将这些添加到你的 build.gradle 中。

implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'

然后将此添加到您的java代码中。

public static ApiInterface getClient() {
        if(retrofitServerOne==null) {
            HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient okHttpClient = new OkHttpClient.Builder()
                    .addNetworkInterceptor(loggingInterceptor)
                    .callTimeout(1,TimeUnit.MINUTES)
                    .connectTimeout(1,TimeUnit.MINUTES)
                    .build();
            retrofitServerOne=new Retrofit.Builder()
                    .baseUrl("Url u need")
                    .addConverterFactory(GsonConverterFactory.create())
                    .client(okHttpClient)
                    .build().create(ApiInterface.class);
        }
        return retrofitServerOne;
    }

试试这种方式,它也会显示 api 调用的日志。 将 ApiInterface 替换为您的接口。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。