gpt4 book ai didi

java - 尝试建立本地连接时出错

转载 作者:行者123 更新时间:2023-12-01 16:30:07 25 4
gpt4 key购买 nike

我试图用以下代码建立本地连接,但由于错误而逐渐弹出。

MainActivity.java

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

GetJsonArray obj = new GetJsonArray();
obj.readJson(this);
}


}

GetJsonArray.java

public class GetJsonArray
{
private String SERVER_URL="http://myIPAddress:portNumber/database_name/table_name.jsp";
private Context context;

public void readJson(final Context context)
{
this.context=context;

Toast.makeText(context,"Inside JSON Array class",Toast.LENGTH_LONG).show();

RequestQueue queue = Volley.newRequestQueue(context);
StringRequest stringRequest = new StringRequest(Request.Method.GET, SERVER_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response)
{
if(response.trim().equals("success"))
{
Toast.makeText(context,"Data recieved from server",Toast.LENGTH_LONG).show();
//Log.e("Success",response);
}
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Toast.makeText(context,"Data not recieved from server",Toast.LENGTH_LONG).show();
//Log.e("Error",error.getLocalizedMessage());
}
}){};
queue.add(stringRequest);
}

}


错误
E / LB:无法打开文件:没有此类文件或目录

最佳答案

您的问题不完整
我需要您的源代码来解决您的问题。
发送我的电子邮件:javaddehban1@gmail.com

关于java - 尝试建立本地连接时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62062872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com