How To Send json Object to the server from my android app

前端 未结 4 908
盖世英雄少女心
盖世英雄少女心 2020-11-30 09:25

I\'m at a bit of a loss as to how to send a jsonobject from my android application to the database

As I am new to this I\'m not too sure where I\'ve gon

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 09:38

    Button submitButton = (Button) findViewById(R.id.submit_button);
    
    submitButton.setOnClickListener(new View.OnClickListener() {
    
        public void onClick(View v) {
    
            JSONObject postData = new JSONObject();
    
            try {
                postData.put("name", name.getText().toString());
                postData.put("address", address.getText().toString());
                postData.put("manufacturer", manufacturer.getText().toString());
                postData.put("location", location.getText().toString());
                postData.put("type", type.getText().toString());
                postData.put("deviceID", deviceID.getText().toString());
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
    

提交回复
热议问题