[Solved] org.json.JSONObject$1 cannot be converted to JSONObject error while parsing json string

After reading JsonArray and JsonObject doc i understand how to sort out this problem. protected void parseJson() { JSONObject object=null; try { object=new JSONObject(json); myArray=object.getJSONArray(MY_ARRAY); Log.e(“Array Length”,””+myArray.length()); key_id=new String[myArray.length()]; key_name=new String[myArray.length()]; for (int i=0;i<=myArray.length();i++) { JSONObject fetchObject=myArray.optJSONObject(i); if(fetchObject==null) { //do nothing } else { key_id[i] = fetchObject.getString(KEY_ID); key_name[i] = fetchObject.getString(KEY_NAME); } } } catch (JSONException … Read more

[Solved] Button to show previous string

create a new member for your Activity like: int actual = 0; Then create a ‘next’ button: nextButton = (Button) findViewById(…); nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { actual = actual < countires.length – 1 ? actual + 1 : actual; String country = countires[actual]; btn1.setText(country); } }); Same goes for the previous … Read more

[Solved] Is it possible to hide the date and time and ip from Mobile Carrier [closed]

First part, mobile carriers: They will always know which server you are connecting to, because it’s them who establish this connection. You’ll have to build up a proxy server, and tunnel the real destination (encrypted) through this proxy. So the carrier will only see the proxy, not the destination. Similar to TOR. Second part, usage … Read more

[Solved] Shape drawable not working?

use this code, <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:top=”4dp” android:right=”4dp” android:bottom=”4dp” android:left=”4dp”> <shape android:shape=”oval”> <solid android:color=”#ff0000″ /> </shape> </item> <item> <shape android:shape=”oval”> <stroke android:width=”2dp” android:color=”#ff0000″/> </shape> </item> </layer-list> using ring shape <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”ring” android:innerRadius=”15dp” android:thickness=”10dp” android:useLevel=”false”> <solid android:color=”#ff0000″ /> </shape> 5 solved Shape drawable not working?

[Solved] function for Phone number to words in java for multiple digits [closed]

Call numToWords with your number. Otherwise if you already have a string just pass it and skip the String.valueOf(number) calling directly the split private static final HashMap<String, String> mapping; static { mapping = new HashMap<>(); mapping.put(“0”, “Zero”); mapping.put(“1”, “One”); mapping.put(“2”, “Two”); mapping.put(“3”, “Three”); mapping.put(“4”, “Four”); mapping.put(“5”, “Five”); mapping.put(“6”, “Six”); mapping.put(“7”, “Seven”); mapping.put(“8”, “Eight”); mapping.put(“9”, “Nine”); … Read more

[Solved] How to pass a text from one activity to all activities?

Just store the text as string in shared preferences and then get the string in other activities.. or you can also use broadcast receiver in all other activities. But first all the activities should call the receiver first then the MainActivity can send the text. In MainActivity, this.getSharedPreferences(“MyPrefName”, Context.MODE_PRIVATE).edit().putString(“parsetext”,”yourtext”).apply(); and in the other activities.. this.getSharedPreferences(“MyPrefName”, … Read more

[Solved] Android JSON parse this, how?

I have tried to parse that JSON string and I got one solution please try this also: String parse = “[{\”hotelid\”:[{\”hotelid\”:\”1\”,\”name\”:\”aaa\”,\”code\”:\”111\”,\”price\”:\”111\”},{\”hotelid\”:\”2\”,\”name\”:\”bbb\”,\”code\”:\”112\”,\”price\”:\”211\”},{\”hotelid\”:\”4\”,\”name\”:\”ccc\”,\”code\”:\”42\”,\”price\”:\”411\”}]}]”; try { JSONArray menuObject = new JSONArray(parse); for(int i=0;i<menuObject.length();i++){ String hotel = menuObject.getJSONObject(i).getString(“hotelid”).toString(); System.out.println(“hotel=”+hotel); JSONArray menuObject1 = new JSONArray(hotel); for(int j=0; j<menuObject1.length();j++){ String hotelid = menuObject1.getJSONObject(j).getString(“hotelid”).toString(); System.out.println(“hotelid==”+hotelid); String name = menuObject1.getJSONObject(j).getString(“name”).toString(); System.out.println(“name==”+name); String code … Read more

[Solved] Value with All number except n or n number in Java [closed]

I’m sorry for my Bad English so you all not uderstand with Question. I’ve solved my problem with this code for(int i=3; i<filteredSubGroupList .length(); i++){ try { filteredSubGroupList = (ProgramMethod.filterArray(subGroupList, “main-group-nr”, String.valueOf(3), false)); } catch (JSONException e) { e.printStackTrace(); } } LOGCAT : I/System.out: 3 I/System.out: [{“zknr”:98,”bezeich”:”CIGARETTE”,”fibukonto”:”14″,”departement”:1,”betriebsnr”:98,”main-group-nr”:3},{“zknr”:700,”bezeich”:”DISCOUNT”,”fibukonto”:”00″,”departement”:1,”betriebsnr”:0,”main-group-nr”:30}] It’s make me get all int except 1 … Read more

[Solved] Fused Location always returns null

Add this code to your onConnected, thats where it would get Last Known Location. private static Location mLastLocation; private static GoogleApiClient mGoogleApiClient; private static Context context; // added private LocationRequest mLocationRequest; private Double latitude; private Double longitude; private String TAG = “”; // set your TAG @Override public void onConnected(Bundle bundle) { if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) … Read more

[Solved] SQL syntax formatting on Android Studio or IntelliJ?

IntelliJ support SQL but only the ultimate edition and since the android studio is built on community edition so consequently, it doesn’t support SQL. I looked it up and PyCharm Community Edition does not support database / SQL only the ultimate edition take a look at this comparison and this solved SQL syntax formatting on … Read more