Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 有人能帮我吗?我有什么问题截击得到请求_Java_Android_Request_Android Volley - Fatal编程技术网

Java 有人能帮我吗?我有什么问题截击得到请求

Java 有人能帮我吗?我有什么问题截击得到请求,java,android,request,android-volley,Java,Android,Request,Android Volley,Score.java 我的代码有点问题,有人能帮我吗 public class Score extends AppCompatActivity { public static String param2; public String param1; private ProgressDialog pDialog; private SessionManager session; private SQLiteHandler db; String id;

Score.java 我的代码有点问题,有人能帮我吗

public class Score extends AppCompatActivity {
    public static String param2;
    public String param1;
    private ProgressDialog pDialog;
    private SessionManager session;
    private SQLiteHandler db;
    String id;
    int n=0;
    private ArrayList<Logsoal> logsoal = new ArrayList<Logsoal>();
    private static String TAG = Score.class.getSimpleName();
    private String urlJsonObj = "http://192.168.43.97:80/sbmptn/web/api/historipengerjaan";
    private String getIdhistori = "http://192.168.43.97:80/sbmptn/web/api/getidhistorypengerjaan";
    private String sendlog = "http://192.168.43.97:80/sbmptn/web/api/logsoal";
    String date,time;
    int id_historypengerjaan=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_score);
        // Progress dialog
        pDialog = new ProgressDialog(this);
        pDialog.setCancelable(false);

        // Session manager
        session = new SessionManager(getApplicationContext());

        // SQLite database handler
        db = new SQLiteHandler(getApplicationContext());

        HashMap<String, String> user = db.getUserDetails();

        id = user.get("id_user");

        Intent i = getIntent();
        Bundle bundle = i.getExtras();
        param1 = bundle.getString("id_bab");
        param2 = bundle.getString("judul");
        n = i.getIntExtra("nilai",0);
        logsoal = (ArrayList<Logsoal>) bundle.getSerializable("log");
        Log.d("Test Log Soal", logsoal+"");
        change_image(n);

    }

    public void goToMain (View view){
        Intent intent = new Intent(this, MenuPage.class);
        intent.putExtra("id_bab",param1);
        intent.putExtra("judul",param2);
        startActivity(intent);
        finish();
    }

    public void goToPembahasan (View view) {
        ConnectivityManager connMgr = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected()) {
            if (session.isLoggedIn()) {
                Calendar c1 = Calendar.getInstance();
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
                SimpleDateFormat sdft = new SimpleDateFormat("HH:mm:ss");
                date = sdf1.format(c1.getTime());
                time = sdft.format(c1.getTime());
                String timetemp = time;
                Log.d("waktu1", time);
                urlJsonObj = "http://192.168.43.97:80/sbmptn/web/api/historipengerjaan?id_user=" + id + "&score=" + n + "&tanggal_pengerjaan=" + date + "&waktu_pengerjaan=" + time;
                Log.d("waktu2", timetemp);
                pDialog.setMessage("Send Data ...");
                showDialog();

                registerHistori();
                getIdhistori = "http://192.168.43.97:80/sbmptn/web/api/getidhistorypengerjaan?tgl=" + date + "&waktu=" + timetemp";

                makeJsonObjectRequest();
                Log.d(TAG, "id histori: "+id_historypengerjaan +" tanggal : "+date+" tanggal : "+time);


                hideDialog();
            } else {
                Toast.makeText(getApplicationContext(),
                        "Please enter your details!", Toast.LENGTH_LONG)
                        .show();
            }
            Intent intent = new Intent(this, pembahasan_soal.class);
            intent.putExtra("id_bab", param1);
            intent.putExtra("judul", param2);
            startActivity(intent);
            finish();
        }else{
            Toast.makeText(getApplicationContext(), "You Must Be Online To Next Access", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(this, MenuPage.class);
            intent.putExtra("id_bab", param1);
            intent.putExtra("judul", param2);
            startActivity(intent);
            finish();
        }
    }

    public void change_image(int point)
    {
        ImageView myPicture=(ImageView)findViewById(R.id.my);
        TextView myText =(TextView)findViewById(R.id.scoreText);
        //use flag to change image
        if(point <= 30)
        {
            myPicture.setImageResource(R.drawable.sad);
            myText.setText("Score Kamu adalah: "+point);
        }
        else if(point>30 && point<=70)
        {
            myPicture.setImageResource(R.drawable.happy1);
            myText.setText("Score Kamu adalah: "+point);
        }
        else if(point>70 && point <=100){
            myPicture.setImageResource(R.drawable.inlove);
            myText.setText("Score Kamu adalah: "+point);
        }
        else{
            myPicture.setImageResource(R.drawable.design);
            myText.setText("Selamat..\nScore Kamu adalah: "+point);
        }
    }

    private void registerHistori() {
        // Tag used to cancel the request
        String tag_string_req = "req_register";

        JsonObjectRequest strReq = new JsonObjectRequest(Request.Method.POST, urlJsonObj, null, new Response.Listener<JSONObject>() {

            @Override
            public void onResponse(JSONObject response) {
                Log.d("Test", "Register Response: " + response.toString());
                hideDialog();

                try {
                    String status = response.getString("status");
                    if (status.equals("1")) {
                        // Launch login activity
                    } else {

                        // Error occurred in registration. Get the error
                        // message
                        String errorMsg = response.getString("Error Please try again");
                        Toast.makeText(getApplicationContext(),
                                errorMsg, Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("erorr :", "Input data Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_LONG).show();
                hideDialog();
            }
        });
        AppController.getInstance().addToRequestQueue(strReq);
    }

    private void makeJsonObjectRequest() {
        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,getIdhistori,null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                JSONArray setdata = new JSONArray();
                Log.d("status", "onResponse: "+ response.toString());
                try {
                    String status = response.getString("status");
                    if(status.equals("1"))
                        setdata = response.getJSONArray("data");
                    for (int i = 0; i < setdata.length(); i++) {
                        JSONObject data = setdata.getJSONObject(i);
                        id_historypengerjaan = data.getInt("id");
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    Toast.makeText(getApplicationContext(),"Error: " + e.getMessage(),Toast.LENGTH_LONG).show();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_SHORT).show();
                // hide the progress dialog
                hideDialog();
            }
        });
        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(jsonObjReq);
        for (int j=0 ; j < logsoal.size();j++){
            sendlog = "http://192.168.43.97:80/sbmptn/web/api/logsoal?id_user=" + id + "&id_soal=" + logsoal.get(j).getId_soal() + "&id_jawabsoal=" + logsoal.get(j).getId_jawabsoal() + "&id_historyPengerjaan=" + id_historypengerjaan;
            Log.d(TAG, "log soal: idsoal : "+logsoal.get(j).getId_soal()+" id_jawab : "+logsoal.get(j).getId_jawabsoal()+" id_histori : "+id_historypengerjaan);
            registerLogsoal();
        }
    }

    private void registerLogsoal() {
        String tag_string_req = "req_register";

        JsonObjectRequest strReq = new JsonObjectRequest(Request.Method.POST, sendlog, null, new Response.Listener<JSONObject>() {

            @Override
            public void onResponse(JSONObject response) {
                Log.d("Test", "Register Response: " + response.toString());
                hideDialog();

                try {
                    String status = response.getString("status");
                    if (status.equals("1")) {
                        // Launch login activity
                    } else {

                        // Error occurred in registration. Get the error
                        // message
                        String errorMsg = response.getString("Error Please try again");
                        Toast.makeText(getApplicationContext(),
                                errorMsg, Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("erorr :", "Input data Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_LONG).show();
                hideDialog();
            }
        });
        AppController.getInstance().addToRequestQueue(strReq);
    }

    private void showDialog() {
        if (!pDialog.isShowing())
            pDialog.show();
    }

    private void hideDialog() {
        if (pDialog.isShowing())
            pDialog.dismiss();
    }

}
public类分数扩展活动{
公共静态字符串param2;
公共字符串参数1;
私人对话;
私人会话管理器会话;
私有SQLiteHandler数据库;
字符串id;
int n=0;
private ArrayList logsoal=new ArrayList();
私有静态字符串标记=Score.class.getSimpleName();
专用字符串urlJsonObj=”http://192.168.43.97:80/sbmptn/web/api/historipengerjaan";
私有字符串getIdhistori=”http://192.168.43.97:80/sbmptn/web/api/getidhistorypengerjaan";
私有字符串sendlog=”http://192.168.43.97:80/sbmptn/web/api/logsoal";
字符串日期、时间;
int id_historypengerjaan=0;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_分数);
//进度对话框
pDialog=新建进度对话框(此对话框);
pDialog.setCancelable(假);
//会话管理器
session=newsessionmanager(getApplicationContext());
//SQLite数据库处理程序
db=新的SQLiteHandler(getApplicationContext());
HashMap user=db.getUserDetails();
id=user.get(“id_user”);
Intent i=getIntent();
Bundle=i.getExtras();
param1=bundle.getString(“id_bab”);
param2=bundle.getString(“judul”);
n=i.getIntExtra(“nilai”,0);
logsoal=(ArrayList)bundle.getSerializable(“log”);
Log.d(“测试日志Soal”,logsoal+”);
改变图像(n);
}
公共void goToMain(视图){
Intent Intent=新Intent(这是MenuPage.class);
意图。putExtra(“id_bab”,参数1);
意图。putExtra(“judul”,第2段);
星触觉(意向);
完成();
}
公共无效Gotopenbahasan(视图){
ConnectivityManager connMgr=(ConnectivityManager)getApplicationContext().getSystemService(Context.CONNECTIVITY\u服务);
NetworkInfo NetworkInfo=connMgr.getActiveNetworkInfo();
if(networkInfo!=null&&networkInfo.isConnected()){
if(session.isLoggedIn()){
Calendar c1=Calendar.getInstance();
SimpleDataFormat sdf1=新SimpleDataFormat(“yyyy-MM-dd”);
SimpleDataFormat sdft=新SimpleDataFormat(“HH:mm:ss”);
date=sdf1.format(c1.getTime());
time=sdft.format(c1.getTime());
字符串timetemp=时间;
Log.d(“waktu1”,时间);
urlJsonObj=”http://192.168.43.97:80/sbmptn/web/api/historipengerjaan?id_user=“+id+”&score=“+n+”&tanggal_pengerjaan=“+date+”&waktu_pengerjaan=“+time;
Log.d(“waktu2”,timetemp);
设置消息(“发送数据…”);
showDialog();
registerHistori();
getIdhistori=”http://192.168.43.97:80/sbmptn/web/api/getidhistorypengerjaan?tgl=“+date+”&waktu=“+timetemp”;
makeJsonObjectRequest();
Log.d(标签,“id histori:+id_historypengerjaan+”tanggal:“+date+”tanggal:“+time”);
hideDialog();
}否则{
Toast.makeText(getApplicationContext(),
“请输入您的详细信息!”,Toast.LENGTH\u LONG)
.show();
}
意向意向=新意向(本类为pembahasan_soal.class);
意图。putExtra(“id_bab”,参数1);
意图。putExtra(“judul”,第2段);
星触觉(意向);
完成();
}否则{
Toast.makeText(getApplicationContext(),“您必须联机才能进行下一次访问”,Toast.LENGTH\u SHORT.show();
Intent Intent=新Intent(这是MenuPage.class);
意图。putExtra(“id_bab”,参数1);
意图。putExtra(“judul”,第2段);
星触觉(意向);
完成();
}
}
公共无效更改_图像(int点)
{
ImageView myPicture=(ImageView)findViewById(R.id.my);
TextView myText=(TextView)findViewById(R.id.scoreText);
//使用标志更改图像

如果在您提供的邮递员请求快照中看到(第30点和第70点和第点),您忘记在URL中附加参数。这些参数是

tgl

瓦克图

下面是应该如何附加参数

private void makeJsonObjectRequest() {

    //Here param1 and param2 should be appropriate parameters.
    getIdhistori=getIdhistory+"tgl="+param1+"&waktu="+param2;

        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,getIdhistori,null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                JSONArray setdata = new JSONArray();
                Log.d("status", "onResponse: "+ response.toString());
                try {
                    String status = response.getString("status");
                    if(status.equals("1"))
                        setdata = response.getJSONArray("data");
                    for (int i = 0; i < setdata.length(); i++) {
                        JSONObject data = setdata.getJSONObject(i);
                        id_historypengerjaan = data.getInt("id");
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    Toast.makeText(getApplicationContext(),"Error: " + e.getMessage(),Toast.LENGTH_LONG).show();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_SHORT).show();
                // hide the progress dialog
                hideDialog();
            }
        });
        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(jsonObjReq);
        for (int j=0 ; j < logsoal.size();j++){
            sendlog = "http://192.168.43.97:80/sbmptn/web/api/logsoal?id_user=" + id + "&id_soal=" + logsoal.get(j).getId_soal() + "&id_jawabsoal=" + logsoal.get(j).getId_jawabsoal() + "&id_historyPengerjaan=" + id_historypengerjaan;
            Log.d(TAG, "log soal: idsoal : "+logsoal.get(j).getId_soal()+" id_jawab : "+logsoal.get(j).getId_jawabsoal()+" id_histori : "+id_historypengerjaan);
            registerLogsoal();
        }
    }
private void makeJsonObjectRequest(){
//这里param1和param2应该是合适的参数。
getIdhistori=getIdhistory+“tgl=“+param1+”&waktu=“+param2;
JsonObjectRequest JSONObjectReq=新的JsonObjectRequest(Request.Method.GET,getIdhistori,null,new Response.Listener()){
@凌驾
公共void onResponse(JSONObject响应){
JSONArray setdata=新的JSONArray();
Log.d(“status”,“onResponse:+response.toString());
试一试{
字符串状态=response.getString(“状态”);
如果(状态等于(“1”))
setdata=response.getJSONArray(“数据”);
对于(int i=0;i