Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Abhay-cloud:Indian-Pincodes-Library:0.4.0'
}
// Example
Boolean isValid = IndianPincodes.isValidPincode(this, "411002");
It will return true if given pincode exists.
// Example
JSONObject OBJ = IndianPincodes.getPincodeByCity(this, "Pune");
try {
JSONArray arr = OBJ.getJSONArray("Result");
for (int i = 0;i<arr.length();i++){
JSONObject obj2 = arr.getJSONObject(i);
Log.d("myapp", "PostOffice: " + obj2.getString("PostOfficeName") + " Pincode " + obj2.getString("pincode"));
}
} catch (JSONException e) {
e.printStackTrace();
}
It will return a JSON Object which will contain "Result" JSON Array
that array will contain bunch (maybe none or one too) of Json objects.
Then you can get information by using obj2.getString("PostOfficeName")
, obj2.getString("pincode")
, etc.
// Example
JSONObject OBJ = IndianPincodes.getStatePincodes(this, "Maharashtra");
try {
JSONArray arr = OBJ.getJSONArray("Result");
for (int i = 0;i<arr.length();i++){
JSONObject obj2 = arr.getJSONObject(i);
Log.d("myapp", "City: " + obj2.getString("City") + " PostOffice: " + obj2.getString("PostOfficeName") + " Pincode " + obj2.getString("pincode"));
}
} catch (JSONException e) {
e.printStackTrace();
}
It will return a JSON Object which will contain "Result" JSON Array that array will contain bunch (maybe none or one too) of Json objects.
Then you can get information by using obj2.getString("City")
, obj2.getString("pincode")
, etc.
// Example
JSONObject OBJ = IndianPincodes.getDistrictPincodes(this, "Pune");
try {
JSONArray arr = OBJ.getJSONArray("Result");
for (int i = 0;i<arr.length();i++){
JSONObject obj2 = arr.getJSONObject(i);
Log.d("myapp", "City: " + obj2.getString("City") + " PostOffice: " + obj2.getString("PostOfficeName") + " Pincode " + obj2.getString("pincode"));
}
} catch (JSONException e) {
e.printStackTrace();
}
It will return a JSON Object which will contain "Result" JSON Array that array will contain bunch (maybe none or one too) of Json objects.
Then you can get information by using obj2.getString("City")
, obj2.getString("pincode")
, etc.
// Example
JSONObject OBJ = IndianPincodes.getInfoByPincode(this, "411002");
try {
JSONArray arr = OBJ.getJSONArray("Result");
for (int i = 0;i<arr.length();i++){
JSONObject obj2 = arr.getJSONObject(i);
Log.d("myapp", "City: " + obj2.getString("City") + " PostOffice: " + obj2.getString("PostOfficeName") + " Pincode " + obj2.getString("pincode")
+ " District: " + obj2.getString("District") + " State: " + obj2.getString("State"));
}
} catch (JSONException e) {
e.printStackTrace();
}
It will return a JSON Object which will contain "Result" JSON Array that array will contain bunch (maybe none or one too) of Json objects.
Then you can get information by using obj2.getString("City")
, obj2.getString("pincode")
, etc.
If you have any difficulty then just message me on Instagram or Telegram.