Custom http library Basic Example with http Request and Response
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.PrudhviBanki:Prudhvi-Http-Library:1.0.0
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// In Request you need to pass current class reference and call back listener
Request request = new Request(this, this);
request.fetchArray(100, Methods.GET, "url", null);
request.fetchObject(101, Methods.GET, "url", null);
}
@Override
public void successObject(JSONObject obj, int requestId) {
// check your condition response and display as Object
}
@Override
public void successArray(JSONArray obj, int requestId) {
// check your condition response and display as JsonArrayList
}
@Override
public void failure(String response, int requestId) {
//Failure response
}
CustomHeaders headers=new CustomHeaders();
headers.setHeader("Authorization","Bearer"+"your token");