JSON值未返回

时间:2014-09-27 07:37:49

标签: android json

我有一些值在KeyValue对中显示为JSON格式。我使用JSON Object获取值并在应用程序中显示。我正在从JSON检查类型和keyvalueStatus。我得到的类型是图片或视频。但是keyvalueStatus总是显示0.在keyvalueStatus下面是1但在app中我得到0并且phonenoButtonName,websiteurlButtonName,websiteurl等返回空值什么都没有。

{
    "type":"image",
    "link":"http:\/\/once.com\/images\/eWFD5ahswOO6X2.jpg",
    "keyvalueStatus":1,
    "phonenoButtonName":"Call",
    "phoneno":"6526268",
    "websiteurlButtonName":"JDO",
    "websiteurl":"once.com",
    "facebookurlButtonName":"fb",
    "facebookurl":"https:\/\/www.facebook.com\/",
    "latestofferurlButtonName":"Offer",
    "latestofferurl":"kart.com"
}

Activity.java:

String type="", link="", overlayurl="",phonenoButtonName="" ,websiteurlButtonName="",websiteurl="",facebookurlButtonName="",
            facebookur="",latestofferurlButtonName="",  latestofferurl="";

    int keyvalueStatus, phoneno;

String json = result.getMetaData();
                JSONObject j = new JSONObject();


                try{
                j= new JSONObject(json);
                type = j.getString("type");
                link = j.getString("link");


                keyvalueStatus=j.getInt("keyvalueStatus");



                phonenoButtonName = j.getString("phonenoButtonName");
                phoneno=j.getInt("phoneno");

                websiteurlButtonName = j.getString("websiteurlButtonName");
                websiteurl = j.getString("websiteurl");

                facebookurlButtonName = j.getString("facebookurlButtonName");
                facebookur = j.getString("facebookur");

                latestofferurlButtonName = j.getString("latestofferurlButtonName");
                latestofferurl = j.getString("latestofferurl");

                }catch(Exception e){

                }

                if(t == 0){
                    t = 1;
                    inflateImageLayout();
                }




                if(type.equalsIgnoreCase("image")){



                    if(keyvalueStatus==0){

                        // Toast.makeText(getApplicationContext(), "Overlay url is"+ keyvalueStatus, 
                                  // Toast.LENGTH_LONG).show();


                        doStopTrackers();
                        //doDeinitTrackers();

                         LoaderImageView ldr = (LoaderImageView) findViewById(R.id.loaderImageView);
                         findViewById(R.id.videoView1).setVisibility(View.INVISIBLE);
                         findViewById(R.id.loaderImageView).setVisibility(View.VISIBLE);
                         findViewById(R.id.button1).setVisibility(View.VISIBLE);
                         ldr.setImageDrawable(link);

                         findViewById(R.id.websiteurl_btn).setVisibility(View.INVISIBLE);
                         findViewById(R.id.facebookur_btn).setVisibility(View.INVISIBLE);
                         findViewById(R.id.latestofferurl_btn).setVisibility(View.INVISIBLE);
                         findViewById(R.id.phoneno_btn).setVisibility(View.INVISIBLE);

                          Log.d(link,LOGTAG1);

                    }else{

                         Toast.makeText(getApplicationContext(), "Overlay url is"+ phoneno, 
                                   Toast.LENGTH_LONG).show();

                        // Toast.makeText(getApplicationContext(), "Overlay url is"+ keyvalueStatus, 
                             //  Toast.LENGTH_LONG).show();

                        // Toast.makeText(getApplicationContext(), "Overlay url is"+ phonenoButtonName, 
                                 //  Toast.LENGTH_LONG).show();

                        doStopTrackers();
                        //doDeinitTrackers();

                         LoaderImageView ldr = (LoaderImageView) findViewById(R.id.loaderImageView);
                         findViewById(R.id.videoView1).setVisibility(View.INVISIBLE);
                         findViewById(R.id.loaderImageView).setVisibility(View.VISIBLE);
                         findViewById(R.id.button1).setVisibility(View.VISIBLE);
                         ldr.setImageDrawable(link);


                         findViewById(R.id.websiteurl_btn).setVisibility(View.INVISIBLE);
                         findViewById(R.id.facebookur_btn).setVisibility(View.INVISIBLE);
                         findViewById(R.id.latestofferurl_btn).setVisibility(View.INVISIBLE);
                         findViewById(R.id.phoneno_btn).setVisibility(View.INVISIBLE);


                          Log.d(link,LOGTAG1);

                    }




                     // image.setImageDrawable(link);



                }

0 个答案:

没有答案