Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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 Android Json值未返回_Java_Php_Android_Json - Fatal编程技术网

Java Android Json值未返回

Java Android Json值未返回,java,php,android,json,Java,Php,Android,Json,我正在开发一个Android应用程序,其中我使用JSon从数据库中获取值。在数据库中,每个字符串A-Z都有特定的文本。当从A-Z返回字符串时,必须显示相应的结果。。。我给出了密码。。但是问题的结果没有显示在。。我使用PHP代码连接 PHP 活动 String custone, costone; TextView txtName9, txtNzme10; // Progress Dialog private ProgressDialog pDialog; // JSON parser class

我正在开发一个Android应用程序,其中我使用JSon从数据库中获取值。在数据库中,每个字符串A-Z都有特定的文本。当从A-Z返回字符串时,必须显示相应的结果。。。我给出了密码。。但是问题的结果没有显示在。。我使用PHP代码连接

PHP

活动

String custone, costone;
TextView txtName9, txtNzme10;
// Progress Dialog
private ProgressDialog pDialog;

// JSON parser class
JSONParser jsonParser = new JSONParser();


private static final String url_cup_stone = "http://iascpl.com/app/get_cup_stone.php";
private static final String url_first_vowel = "http://iascpl.com/app/get_first_vowel.php";

private static final String TAG_CUPSTONE = "cupstone";
private static final String TAG_FIRSTVOWEL = "firstvowel";

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

    txt27.setText(getIntent().getStringExtra("aChar"));
    TextView txt28 = (TextView) findViewById(R.id.textView51);
    txt28.setText(getIntent().getStringExtra("aChar1"));


    costone = txt27.getText().toString();
    custone = txt28.getText().toString();


    /**
     * Background Async Task to Get complete product details
     * */
    class GetProductDetails extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(FullExplanation.this);
            pDialog.setMessage("Loading the result... Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        /**
         * Getting product details in background thread
         * */
        protected String doInBackground(String... args)

        {

            TextView txt27 = (TextView) findViewById(R.id.textView48);
            TextView txt28 = (TextView) findViewById(R.id.textView51);

            costone = txt27.getText().toString();
            custone = txt28.getText().toString();

            params.add(new BasicNameValuePair("costone", costone));
            params.add(new BasicNameValuePair("custone", custone));

            JSONObject json9 = jsonParser.makeHttpRequest(
                    url_corner_stone, "GET", params);

            JSONObject json10 = jsonParser.makeHttpRequest(
                    url_cup_stone, "GET", params);

            int success9 = json9.getInt(TAG_SUCCESS);
            int success10 = json10.getInt(TAG_SUCCESS);

            if (success9 == 1) {
                // successfully received product details
                JSONArray productObj = json9
                        .getJSONArray(TAG_PRODUCT); // JSON Array

                // get first product object from JSON Array
                final JSONObject product = productObj.getJSONObject(0);

                // product with this pid found
                // Edit Text

                txtName9 = (TextView) findViewById(R.id.textView49);


                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        try {

                            txtName9.setText(product.getString(TAG_CORNERSTONE));
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });

            } else {
                // product with pid not found
            }

            if (success10 == 1) {
                // successfully received product details
                JSONArray productObj = json10
                        .getJSONArray(TAG_PRODUCT); // JSON Array

                // get first product object from JSON Array
                final JSONObject product = productObj.getJSONObject(0);

                // product with this pid found
                // Edit Text

                txtName10 = (TextView) findViewById(R.id.textView52);


                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        try {

                            txtName10.setText(product.getString(TAG_CUPSTONE));
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });

            } else {
                // product with pid not found
            }

        }

        catch(
        JSONException e
        )

        {
            e.printStackTrace();
        }

        return null;
    }


    /**
     * After completing background task Dismiss the progress dialog
     * **/

protected void onPostExecute(String file_url) {
    // dismiss the dialog once got all details
    pDialog.dismiss();
}
字符串custone,costone;
TextView txtName9、txtNzme10;
//进度对话框
私人对话;
//JSON解析器类
JSONParser JSONParser=新的JSONParser();
私有静态最终字符串url_cup_stone=”http://iascpl.com/app/get_cup_stone.php";
私有静态最终字符串url_first_元音=”http://iascpl.com/app/get_first_vowel.php";
私有静态最终字符串标记_CUPSTONE=“CUPSTONE”;
私有静态最终字符串标记_FIRSTVOWEL=“FIRSTVOWEL”;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.fullexplainion_xm);
setText(getIntent().getStringExtra(“aChar”);
TextView txt28=(TextView)findViewById(R.id.textView51);
setText(getIntent().getStringExtra(“aChar1”);
costone=txt27.getText().toString();
custone=txt28.getText().toString();
/**
*获取完整产品详细信息的后台异步任务
* */
类GetProductDetails扩展了AsyncTask{
/**
*在启动后台线程显示进度对话框之前
* */
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
pDialog=新建进度对话框(fullexplainion.this);
setMessage(“正在加载结果…请稍候…”);
pDialog.setUndeterminate(假);
pDialog.setCancelable(真);
pDialog.show();
}
/**
*在后台线程中获取产品详细信息
* */
受保护的字符串doInBackground(字符串…args)
{
TextView txt27=(TextView)findViewById(R.id.textView48);
TextView txt28=(TextView)findViewById(R.id.textView51);
costone=txt27.getText().toString();
custone=txt28.getText().toString();
参数添加(新的BasicNameValuePair(“costone”,costone));
参数添加(新的BasicNameValuePair(“custone”,custone));
JSONObject json9=jsonParser.makeHttpRequest(
url_corner_stone,“GET”,params);
JSONObject json10=jsonParser.makeHttpRequest(
url_cup_stone,“GET”,params);
int success9=json9.getInt(TAG_SUCCESS);
int success10=json10.getInt(TAG_SUCCESS);
如果(成功9==1){
//已成功接收产品详细信息
JSONArray productObj=json9
.getJSONArray(TAG_PRODUCT);//JSON数组
//从JSON数组中获取第一个产品对象
最终JSONObject产品=productObj.getJSONObject(0);
//找到具有此pid的产品
//编辑文本
txtName9=(TextView)findViewById(R.id.textView49);
runOnUiThread(新的Runnable(){
@凌驾
公开募捐{
//TODO自动生成的方法存根
试一试{
setText(product.getString(TAG_));
}捕获(JSONException e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
});
}否则{
//找不到具有pid的产品
}
如果(成功10==1){
//已成功接收产品详细信息
JSONArray productObj=json10
.getJSONArray(TAG_PRODUCT);//JSON数组
//从JSON数组中获取第一个产品对象
最终JSONObject产品=productObj.getJSONObject(0);
//找到具有此pid的产品
//编辑文本
txtName10=(TextView)findViewById(R.id.textView52);
runOnUiThread(新的Runnable(){
@凌驾
公开募捐{
//TODO自动生成的方法存根
试一试{
txtName10.setText(product.getString(TAG_CUPSTONE));
}捕获(JSONException e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
});
}否则{
//找不到具有pid的产品
}
}
抓住(
JSONException e
)
{
e、 printStackTrace();
}
返回null;
}
/**
*完成后台任务后,关闭“进度”对话框
* **/
受保护的void onPostExecute(字符串文件\u url){
//获得所有详细信息后关闭对话框
pDialog.disclose();
}

}

您无法初始化
TextView
内部
doInBackground
需要初始化
OnCreate
。有人能帮我吗。。
String custone, costone;
TextView txtName9, txtNzme10;
// Progress Dialog
private ProgressDialog pDialog;

// JSON parser class
JSONParser jsonParser = new JSONParser();


private static final String url_cup_stone = "http://iascpl.com/app/get_cup_stone.php";
private static final String url_first_vowel = "http://iascpl.com/app/get_first_vowel.php";

private static final String TAG_CUPSTONE = "cupstone";
private static final String TAG_FIRSTVOWEL = "firstvowel";

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

    txt27.setText(getIntent().getStringExtra("aChar"));
    TextView txt28 = (TextView) findViewById(R.id.textView51);
    txt28.setText(getIntent().getStringExtra("aChar1"));


    costone = txt27.getText().toString();
    custone = txt28.getText().toString();


    /**
     * Background Async Task to Get complete product details
     * */
    class GetProductDetails extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(FullExplanation.this);
            pDialog.setMessage("Loading the result... Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        /**
         * Getting product details in background thread
         * */
        protected String doInBackground(String... args)

        {

            TextView txt27 = (TextView) findViewById(R.id.textView48);
            TextView txt28 = (TextView) findViewById(R.id.textView51);

            costone = txt27.getText().toString();
            custone = txt28.getText().toString();

            params.add(new BasicNameValuePair("costone", costone));
            params.add(new BasicNameValuePair("custone", custone));

            JSONObject json9 = jsonParser.makeHttpRequest(
                    url_corner_stone, "GET", params);

            JSONObject json10 = jsonParser.makeHttpRequest(
                    url_cup_stone, "GET", params);

            int success9 = json9.getInt(TAG_SUCCESS);
            int success10 = json10.getInt(TAG_SUCCESS);

            if (success9 == 1) {
                // successfully received product details
                JSONArray productObj = json9
                        .getJSONArray(TAG_PRODUCT); // JSON Array

                // get first product object from JSON Array
                final JSONObject product = productObj.getJSONObject(0);

                // product with this pid found
                // Edit Text

                txtName9 = (TextView) findViewById(R.id.textView49);


                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        try {

                            txtName9.setText(product.getString(TAG_CORNERSTONE));
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });

            } else {
                // product with pid not found
            }

            if (success10 == 1) {
                // successfully received product details
                JSONArray productObj = json10
                        .getJSONArray(TAG_PRODUCT); // JSON Array

                // get first product object from JSON Array
                final JSONObject product = productObj.getJSONObject(0);

                // product with this pid found
                // Edit Text

                txtName10 = (TextView) findViewById(R.id.textView52);


                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        try {

                            txtName10.setText(product.getString(TAG_CUPSTONE));
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });

            } else {
                // product with pid not found
            }

        }

        catch(
        JSONException e
        )

        {
            e.printStackTrace();
        }

        return null;
    }


    /**
     * After completing background task Dismiss the progress dialog
     * **/

protected void onPostExecute(String file_url) {
    // dismiss the dialog once got all details
    pDialog.dismiss();
}