Example usage for org.json JSONException printStackTrace

List of usage examples for org.json JSONException printStackTrace

Introduction

In this page you can find the example usage for org.json JSONException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.zeroone_creative.basicapplication.view.activity.WelcomeActivity.java

@Click(R.id.welcome_imagebutton_register)
void clickRegist() {
    findViewById(R.id.welcome_imagebutton_register).setEnabled(false);

    JSONRequestUtil createUserRequest = new JSONRequestUtil(new NetworkTaskCallback() {
        @Override//from w w w  . jav  a  2  s  .c o m
        public void onSuccessNetworkTask(int taskId, Object object) {
            mContext.getSharedPreferences(AppConfig.PREF_NAME, Context.MODE_PRIVATE).edit()
                    .putString(AppConfig.PREF_KEY_USER, object.toString()).commit();
            RegistActivity_.intent(mContext).start();
        }

        @Override
        public void onFailedNetworkTask(int taskId, Object object) {
            Toast.makeText(mContext, getString(R.string.common_faild_network), Toast.LENGTH_SHORT).show();
        }
    }, this.getClass().getSimpleName(), null);
    JSONObject params = new JSONObject();
    try {
        params.put("name", mUserIdEditText.getText().toString());
    } catch (JSONException e) {
        e.printStackTrace();
    }
    createUserRequest.onRequest(VolleyHelper.getRequestQueue(this), Request.Priority.HIGH,
            UriUtil.postCreateUser(), NetworkTasks.Createuser, params);
}

From source file:com.github.akinaru.hcidebugger.activity.DescriptionActivity.java

protected void onCreate(Bundle savedInstanceState) {

    setLayout(R.layout.description_activity);
    super.onCreate(savedInstanceState);

    //setup navigation items
    setupDrawerContent(nvDrawer);/*from ww  w.  ja  va 2  s.c o  m*/

    //hide max packet count for this activity
    nvDrawer.getMenu().findItem(R.id.set_max_packet_num).setVisible(false);
    nvDrawer.getMenu().findItem(R.id.browse_file).setVisible(false);
    nvDrawer.getMenu().findItem(R.id.change_settings).setVisible(false);

    //get information sent via intent to be displayed
    String hciPacket = getIntent().getExtras().getString(Constants.INTENT_HCI_PACKET);
    String snoopPacket = getIntent().getExtras().getString(Constants.INTENT_SNOOP_PACKET);
    int packetNumber = getIntent().getExtras().getInt(Constants.INTENT_PACKET_NUMBER);
    String ts = getIntent().getExtras().getString(Constants.INTENT_PACKET_TS);
    String packet_type = getIntent().getExtras().getString(Constants.INTENT_PACKET_TYPE);
    String destination = getIntent().getExtras().getString(Constants.INTENT_PACKET_DEST);

    //setup description item table
    tablelayout = (TableLayout) findViewById(R.id.tablelayout);
    altTableRow(2);

    //setup json highlishter web page
    WebView lWebView = (WebView) findViewById(R.id.webView);

    TextView number_value = (TextView) findViewById(R.id.number_value);
    TextView ts_value = (TextView) findViewById(R.id.ts_value);
    TextView packet_type_value = (TextView) findViewById(R.id.packet_type_value);
    TextView destination_value = (TextView) findViewById(R.id.dest_value);
    number_value.setText("" + packetNumber);
    ts_value.setText(ts);
    packet_type_value.setText(packet_type);
    destination_value.setText(destination);

    WebSettings webSettings = lWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    int spacesToIndentEachLevel = 2;
    String beautify = "{}";
    try {
        beautify = new JSONObject(hciPacket).toString(spacesToIndentEachLevel);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    String html = "<HTML><HEAD><link rel=\"stylesheet\" href=\"styles.css\">"
            + "<script src=\"highlight.js\"></script>" + "<script>hljs.initHighlightingOnLoad();</script>"
            + "</HEAD><body>" + "<pre><code class=\"json\">" + beautify + "</code></pre>" + "</body></HTML>";

    lWebView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
}

From source file:com.seunghyo.sunshine.FetchWeatherTask.java

/**
 * Take the String representing the complete forecast in JSON Format and
 * pull out the data we need to construct the Strings needed for the wireframes.
 *
 * Fortunately parsing is easy:  constructor takes the JSON string and converts it
 * into an Object hierarchy for us./*from   w  w  w .ja va 2 s  . c om*/
 */
private String[] getWeatherDataFromJson(String forecastJsonStr, String locationSetting) throws JSONException {

    // Now we have a String representing the complete forecast in JSON Format.
    // Fortunately parsing is easy:  constructor takes the JSON string and converts it
    // into an Object hierarchy for us.

    // These are the names of the JSON objects that need to be extracted.

    // Location information
    final String OWM_CITY = "city";
    final String OWM_CITY_NAME = "name";
    final String OWM_COORD = "coord";

    // Location coordinate
    final String OWM_LATITUDE = "lat";
    final String OWM_LONGITUDE = "lon";

    // Weather information.  Each day's forecast info is an element of the "list" array.
    final String OWM_LIST = "list";

    final String OWM_PRESSURE = "pressure";
    final String OWM_HUMIDITY = "humidity";
    final String OWM_WINDSPEED = "speed";
    final String OWM_WIND_DIRECTION = "deg";

    // All temperatures are children of the "temp" object.
    final String OWM_TEMPERATURE = "temp";
    final String OWM_MAX = "max";
    final String OWM_MIN = "min";

    final String OWM_WEATHER = "weather";
    final String OWM_DESCRIPTION = "main";
    final String OWM_WEATHER_ID = "id";

    try {
        JSONObject forecastJson = new JSONObject(forecastJsonStr);
        JSONArray weatherArray = forecastJson.getJSONArray(OWM_LIST);

        JSONObject cityJson = forecastJson.getJSONObject(OWM_CITY);
        String cityName = cityJson.getString(OWM_CITY_NAME);

        JSONObject cityCoord = cityJson.getJSONObject(OWM_COORD);
        double cityLatitude = cityCoord.getDouble(OWM_LATITUDE);
        double cityLongitude = cityCoord.getDouble(OWM_LONGITUDE);

        long locationId = addLocation(locationSetting, cityName, cityLatitude, cityLongitude);

        // Insert the new weather information into the database
        Vector<ContentValues> cVVector = new Vector<ContentValues>(weatherArray.length());

        // OWM returns daily forecasts based upon the local time of the city that is being
        // asked for, which means that we need to know the GMT offset to translate this data
        // properly.

        // Since this data is also sent in-order and the first day is always the
        // current day, we're going to take advantage of that to get a nice
        // normalized UTC date for all of our weather.

        Time dayTime = new Time();
        dayTime.setToNow();

        // we start at the day returned by local time. Otherwise this is a mess.
        int julianStartDay = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);

        // now we work exclusively in UTC
        dayTime = new Time();

        for (int i = 0; i < weatherArray.length(); i++) {
            // These are the values that will be collected.
            long dateTime;
            double pressure;
            int humidity;
            double windSpeed;
            double windDirection;

            double high;
            double low;

            String description;
            int weatherId;

            // Get the JSON object representing the day
            JSONObject dayForecast = weatherArray.getJSONObject(i);

            // Cheating to convert this to UTC time, which is what we want anyhow
            dateTime = dayTime.setJulianDay(julianStartDay + i);

            pressure = dayForecast.getDouble(OWM_PRESSURE);
            humidity = dayForecast.getInt(OWM_HUMIDITY);
            windSpeed = dayForecast.getDouble(OWM_WINDSPEED);
            windDirection = dayForecast.getDouble(OWM_WIND_DIRECTION);

            // Description is in a child array called "weather", which is 1 element long.
            // That element also contains a weather code.
            JSONObject weatherObject = dayForecast.getJSONArray(OWM_WEATHER).getJSONObject(0);
            description = weatherObject.getString(OWM_DESCRIPTION);
            weatherId = weatherObject.getInt(OWM_WEATHER_ID);

            // Temperatures are in a child object called "temp".  Try not to name variables
            // "temp" when working with temperature.  It confuses everybody.
            JSONObject temperatureObject = dayForecast.getJSONObject(OWM_TEMPERATURE);
            high = temperatureObject.getDouble(OWM_MAX);
            low = temperatureObject.getDouble(OWM_MIN);

            ContentValues weatherValues = new ContentValues();

            weatherValues.put(WeatherEntry.COLUMN_LOC_KEY, locationId);
            weatherValues.put(WeatherEntry.COLUMN_DATE, dateTime);
            weatherValues.put(WeatherEntry.COLUMN_HUMIDITY, humidity);
            weatherValues.put(WeatherEntry.COLUMN_PRESSURE, pressure);
            weatherValues.put(WeatherEntry.COLUMN_WIND_SPEED, windSpeed);
            weatherValues.put(WeatherEntry.COLUMN_DEGREES, windDirection);
            weatherValues.put(WeatherEntry.COLUMN_MAX_TEMP, high);
            weatherValues.put(WeatherEntry.COLUMN_MIN_TEMP, low);
            weatherValues.put(WeatherEntry.COLUMN_SHORT_DESC, description);
            weatherValues.put(WeatherEntry.COLUMN_WEATHER_ID, weatherId);

            cVVector.add(weatherValues);
        }

        // add to database
        if (cVVector.size() > 0) {
            // Student: call bulkInsert to add the weatherEntries to the database here
        }

        // Sort order:  Ascending, by date.
        String sortOrder = WeatherEntry.COLUMN_DATE + " ASC";
        Uri weatherForLocationUri = WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
                System.currentTimeMillis());

        // Students: Uncomment the next lines to display what what you stored in the bulkInsert

        //            Cursor cur = mContext.getContentResolver().query(weatherForLocationUri,
        //                    null, null, null, sortOrder);
        //
        //            cVVector = new Vector<ContentValues>(cur.getCount());
        //            if ( cur.moveToFirst() ) {
        //                do {
        //                    ContentValues cv = new ContentValues();
        //                    DatabaseUtils.cursorRowToContentValues(cur, cv);
        //                    cVVector.add(cv);
        //                } while (cur.moveToNext());
        //            }

        Log.d(LOG_TAG, "FetchWeatherTask Complete. " + cVVector.size() + " Inserted");

        String[] resultStrs = convertContentValuesToUXFormat(cVVector);
        return resultStrs;

    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    }
    return null;
}

From source file:com.example.igorklimov.popularmoviesdemo.sync.SyncAdapter.java

private void getData() {
    int sortByPreference = Utility.getSortByPreference(mContext);
    Uri contentUri = null;/*from  w  w w .j av a2  s  .  co  m*/

    if (sortByPreference != 4) {
        String sortType = null;
        switch (sortByPreference) {
        case 1:
            sortType = POPULARITY_DESC;
            contentUri = MovieByPopularity.CONTENT_URI;
            break;
        case 2:
            sortType = formatDate();
            contentUri = MovieByReleaseDate.CONTENT_URI;
            break;
        case 3:
            sortType = VOTE_AVG_DESC;
            contentUri = MovieByVotes.CONTENT_URI;
            break;
        }

        Cursor cursor = mContentResolver.query(contentUri, null, null, null, null);
        int page = Utility.getPagePreference(mContext);
        int count = cursor.getCount();
        if (count == 0)
            page = 1;
        Log.d(LOG_TAG, "onPerformSync: cursorCount " + count + " page: " + page);
        if (count < page * 20) {
            String jsonResponse = getJsonResponse(DISCOVER_MOVIES + SORT_BY + sortType + PAGE + page + API_KEY);

            if (jsonResponse != null) {
                JSONObject[] JsonMovies = getJsonMovies(jsonResponse);
                try {
                    Log.d(LOG_TAG, "INSERTING EXTRA DATA");
                    int i = 0;
                    for (JSONObject jsonMovie : JsonMovies) {
                        String poster = IMAGE_BASE + W_185 + jsonMovie.getString("poster_path");
                        String backdropPath = IMAGE_BASE + "/w500" + jsonMovie.getString("backdrop_path");
                        String title = jsonMovie.getString("title");
                        String releaseDate = jsonMovie.getString("release_date");
                        String vote = jsonMovie.getString("vote_average");
                        String plot = jsonMovie.getString("overview");
                        String genres = Utility.formatGenres(getGenres(jsonMovie));
                        String id = jsonMovie.getString("id");

                        ContentValues values = new ContentValues();
                        values.put(COLUMN_TITLE, title);
                        values.put(COLUMN_POSTER, poster);
                        values.put(COLUMN_RELEASE_DATE, releaseDate);
                        values.put(COLUMN_GENRES, genres);
                        values.put(COLUMN_MOVIE_ID, id);
                        values.put(COLUMN_BACKDROP_PATH, backdropPath);
                        values.put(COLUMN_AVERAGE_VOTE, vote);
                        values.put(COLUMN_PLOT, plot);

                        mContentValues[i++] = values;
                    }
                    int bulkInsert = mContentResolver.bulkInsert(contentUri, mContentValues);
                    Log.d(LOG_TAG, "onPerformSync: bulkInsert " + bulkInsert);
                    cursor.close();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.atinternet.tracker.Tool.java

/**
 * Convert a JSONObject to Map//from  w ww  . j  ava2 s  .  c o  m
 *
 * @param jsonObject JSONObject
 * @return Map
 */
static Map toMap(JSONObject jsonObject) {
    Map<String, Object> map = new HashMap<String, Object>();

    Iterator<String> keysItr = jsonObject.keys();
    while (keysItr.hasNext()) {
        String key = keysItr.next();
        Object value = null;
        try {
            value = jsonObject.get(key);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        map.put(key, value);
    }
    return map;
}

From source file:com.bindez.nlp.converter.RabbitConverter.java

public static String replace_with_rule(String rule, String output) {

    try {/*www .j  a  va2 s  . c om*/
        JSONArray rule_array = new JSONArray(rule);
        int max_loop = rule_array.length();

        //because of JDK 7 bugs in Android
        output = output.replace("null", "\uFFFF\uFFFF");

        for (int i = 0; i < max_loop; i++) {

            JSONObject obj = rule_array.getJSONObject(i);
            String from = obj.getString("from");
            String to = obj.getString("to");

            output = output.replaceAll(from, to);
            output = output.replace("null", "");

        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    output = output.replace("\uFFFF\uFFFF", "null");
    return output;
}

From source file:cn.ttyhuo.activity.InfoOwnerActivity.java

protected void setupViewOfHasLogin(JSONObject jObject) {
    try {/*  www. j  a  v a 2  s.  c  o  m*/

        ArrayList<String> pics = new ArrayList<String>();
        JSONArray jsonArray = jObject.optJSONArray("imageList");
        if (jsonArray != null) {
            for (int s = 0; s < jsonArray.length(); s++)
                pics.add(jsonArray.getString(s));
        }
        while (pics.size() < 3)
            pics.add("plus");
        mPicData = pics;
        mPicAdapter.updateData(pics);

        if (jObject.getBoolean("isTruckVerified")) {
            tv_edit_tips.setText("?????");
        } else if (jsonArray != null && jsonArray.length() > 2 && jObject.has("truckInfo")) {
            tv_edit_tips.setText(
                    "?????????");
        } else {
            tv_edit_tips.setText("??????");
        }

        if (jObject.has("truckInfo")) {
            JSONObject userJsonObj = jObject.getJSONObject("truckInfo");
            if (!userJsonObj.optString("licensePlate").isEmpty()
                    && userJsonObj.optString("licensePlate") != "null")
                mEditChepai.setText(userJsonObj.getString("licensePlate"));
            Integer truckType = userJsonObj.getInt("truckType");
            if (truckType != null && truckType > 0)
                mEditChexing.setText(ConstHolder.TruckTypeItems[truckType - 1]);
            else
                mEditChexing.setText("");
            if (!userJsonObj.optString("loadLimit").isEmpty() && userJsonObj.optString("loadLimit") != "null")
                mEditZaizhong.setText(userJsonObj.getString("loadLimit"));
            if (!userJsonObj.optString("truckLength").isEmpty()
                    && userJsonObj.optString("truckLength") != "null")
                mEditChechang.setText(userJsonObj.getString("truckLength"));
            if (!userJsonObj.optString("modelNumber").isEmpty()
                    && userJsonObj.optString("modelNumber") != "null")
                mEditXinghao.setText(userJsonObj.getString("modelNumber"));

            if (!userJsonObj.optString("seatingCapacity").isEmpty()
                    && userJsonObj.optString("seatingCapacity") != "null")
                mEditZuowei.setText(userJsonObj.getString("seatingCapacity"));
            if (!userJsonObj.optString("releaseYear").isEmpty()
                    && userJsonObj.optString("releaseYear") != "null")
                mEditDate.setText(userJsonObj.getString("releaseYear") + "");
            if (!userJsonObj.optString("truckWidth").isEmpty() && userJsonObj.optString("truckWidth") != "null")
                mEditKuan.setText(userJsonObj.getString("truckWidth"));
            if (!userJsonObj.optString("truckHeight").isEmpty()
                    && userJsonObj.optString("truckHeight") != "null")
                mEditGao.setText(userJsonObj.getString("truckHeight"));
        }

        if (!jObject.getBoolean("isTruckVerified")) {
            mEditChexing.setOnClickListener(this);
            mEditDate.setOnClickListener(this);
            mEditChepai.setFocusable(true);
            mEditChepai.setEnabled(true);
            mEditZaizhong.setFocusable(true);
            mEditZaizhong.setEnabled(true);
            mEditChechang.setFocusable(true);
            mEditChechang.setEnabled(true);
            mEditZuowei.setFocusable(true);
            mEditZuowei.setEnabled(true);
            mEditKuan.setFocusable(true);
            mEditKuan.setEnabled(true);
            mEditGao.setFocusable(true);
            mEditGao.setEnabled(true);
            mEditXinghao.setFocusable(true);
            mEditXinghao.setEnabled(true);
            canUpdate = true;
        } else {
            mPicGrid.setOnItemLongClickListener(null);

            mEditChepai.setFocusable(false);
            mEditChepai.setEnabled(false);
            mEditZaizhong.setFocusable(false);
            mEditZaizhong.setEnabled(false);
            mEditChechang.setFocusable(false);
            mEditChechang.setEnabled(false);
            mEditZuowei.setFocusable(false);
            mEditZuowei.setEnabled(false);
            mEditKuan.setFocusable(false);
            mEditKuan.setEnabled(false);
            mEditGao.setFocusable(false);
            mEditGao.setEnabled(false);
            mEditXinghao.setFocusable(false);
            mEditXinghao.setEnabled(false);
            canUpdate = false;
        }

        saveParams(true);

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.UAE.ibeaconreference.AppEngineClient.java

public static JSONObject getJSONObject(String s) {

    JSONObject jsonObj = null;//w  w  w  . j a  va2s.c o m

    //s = s.replace('"', '\"');
    try {
        jsonObj = new JSONObject(s);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return jsonObj;
}

From source file:com.UAE.ibeaconreference.AppEngineClient.java

public String getTokenFromServer() {
    String s = null;//from w  w  w.j  a v  a2  s  .  c  o m
    try {

        URL uri = new URL("https://rtonames.sprintlabs.io/token");

        Map<String, List<String>> headers = new HashMap<String, List<String>>();

        String key = "Authorization";
        String authStr = "6eece178-9fcf-45b7-ab50-08b8066daabe:e494a4e72b6f7c7672b74d311cbabf2672be8c24c9496554077936097195a5ac69b6acd11eb09a1ae07a40d2e7f0348d";
        String encoding = Base64.encodeToString(authStr.getBytes(), Base64.DEFAULT);
        encoding = encoding.replace("\n", "").replace("\r", "");

        System.out.println(encoding);
        List<String> value = Arrays.asList("Basic " + encoding);

        headers.put(key, value);

        AppEngineClient aec1 = new AppEngineClient();
        Request request = aec1.new GET(uri, headers);

        AsyncTask<Request, Void, Response> obj = new asyncclass().execute(request);

        Response response = obj.get();

        obj.cancel(true);

        obj = null;

        String body = null;
        try {
            body = new String(response.body, "UTF-8");
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        JSONObject tokenjson = AppEngineClient.getJSONObject(body);

        if (tokenjson.has("token")) {
            try {
                s = tokenjson.getString("token");
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return s;
}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_addcase_step2);
    // load title from strings.xml
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
    // load icons from strings.xml
    navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);
    set(navMenuTitles, navMenuIcons);/*from ww w .jav  a 2  s  . co m*/
    //Toast.makeText(AddCaseStep2of4.this, "reachec in AddCaseStep1of 4", Toast.LENGTH_SHORT).show();

    // Find the SharedPreferences Firstname
    SharedPreferences FirstName = getSharedPreferences("LoginData", Context.MODE_PRIVATE);
    String FirName = FirstName.getString("FIRSETNAME", "");
    TextView welcome = (TextView) findViewById(R.id.textView_welcome);
    welcome.setText("Welcome " + FirName);

    // Find Mesaage Text and Edit field by Id
    messageText = (TextView) findViewById(R.id.messageText);
    edittextFile = (EditText) findViewById(R.id.editText_AddCaseStep1Browse);

    // Find By Id spinner Address To Use
    spinnerpropertyTitleType = (Spinner) findViewById(R.id.TitleType);
    spinnerpropertyPROJECT = (Spinner) findViewById(R.id.projectsp);
    spinnerpropertyLSTCHG_BANKNAME = (Spinner) findViewById(R.id.banksp);
    spinnerpropertyDEVELOPER = (Spinner) findViewById(R.id.developersp);
    spinnerpropertyDEVSOLICTOR = (Spinner) findViewById(R.id.DevSolisp);
    spinnerpropertySTATE = (Spinner) findViewById(R.id.state);

    QryGroup13 = (CheckBox) findViewById(R.id.PropetyCharged);

    // Spinner click listener
    spinnerpropertySTATE.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            stateval_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            stateval = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinnerpropertyTitleType.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            titleValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            titleValue = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinnerpropertyPROJECT.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            ProjectValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            ProjectValue = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinnerpropertyLSTCHG_BANKNAME.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            bankValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            bankValue = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinnerpropertyDEVELOPER.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            developerValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            developerValue = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinnerpropertyDEVSOLICTOR.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            solicitorValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            solicitorValue = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Find button by Id
    btnpdf1 = (ZoomButton) findViewById(R.id.zoomButton_propertyPdf1);
    //btnpdf2 = (ZoomButton) findViewById(R.id.zoomButton_propertyPdf2);
    buttonconfirm = (Button) findViewById(R.id.button_PropertyConfirm);
    walkin = (Button) findViewById(R.id.button_PropertyWalkin);

    // Find EditText Fields
    Title = (EditText) findViewById(R.id.editText_ProperTytitleNo);
    LotType = (EditText) findViewById(R.id.editText_PropertyLottype);
    LotNo = (EditText) findViewById(R.id.editText_PropertyLotPTDNo);
    Knownas = (EditText) findViewById(R.id.editText_PropertyFormerlyKnownAs);
    Pekan = (EditText) findViewById(R.id.editText_PropertyBandarPekanMukin);
    Daerah = (EditText) findViewById(R.id.editText_PropertyDaerahState);
    Nageri = (EditText) findViewById(R.id.editText_PropertyNageriArea);

    LotArea = (EditText) findViewById(R.id.editText_PropertyLotArea);
    LastUpdate = (EditText) findViewById(R.id.editText_PropertyLastUpdateOn);
    DevLicense = (EditText) findViewById(R.id.editText_PropertyDevLicense);
    SolicitorLoc = (EditText) findViewById(R.id.editText_PropertySolicitorLoc);
    Branch = (EditText) findViewById(R.id.editText_PropertyBranch);
    PAName = (EditText) findViewById(R.id.editText_PropertyPAName);
    PresentaionNo = (EditText) findViewById(R.id.editText_PropertyPresentaionNo);
    PurchasePrice = (EditText) findViewById(R.id.editText_PurchasePrice);

    btnpdf1.setOnClickListener(this);
    //btnpdf2.setOnClickListener(this);
    buttonconfirm.setOnClickListener(this);
    walkin.setOnClickListener(this);

    //Toast.makeText(AddCaseStep2of4.this, " Can't Read The Scanned Files. Kindly Key In the Data.", Toast.LENGTH_SHORT).show();

    //Get Data From Document

    Intent intent = getIntent();

    String jsonArray = intent.getStringExtra("jsonArray");
    if (!jsonArray.isEmpty()) {
        try {
            JSONObject array = new JSONObject(jsonArray);

            setallvalues(array);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else
        Toast.makeText(AddCaseStep2of4.this, " Can't Read The Scanned Files. Kindly Key In the Data.",
                Toast.LENGTH_SHORT).show();

    try {
        dropdownTitle();
        dropdownBankDeveloperSolicitor();
        dropdownPorject();
        dropdownState();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}