Easy to make HTTP Request. Easy to manage cookies with HTTP Request and HTTP Response. An automated cookies manager library for android.
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
compile 'com.github.IntruderShanky:Milano:2.0.2'
compile 'com.intrusoft.milano:milano:2.0.2'
- Easy to make HTTP Request.
- Easy to manage cookies.
- Automatic Mangage Cookies.
- Customizable HTTP Request
Milano.with(MainActivity.this)
.fromURL("https://your_api.com/data")
.doGet()
.shouldManageCookies(true) //if false then will not set cookies to request or retrieve cookies from response.
.execute(new OnRequestComplete() {
@Override
public void onSuccess(String response, int responseCode) {
//Do whatever you want to do
addText("\nResponse: " + response);
}
@Override
public void onError(String error, int errorCode) {
//Do whatever you want to do
addText("\nError: " + error);
}
});
Milano.Builder builder = new Milano.Builder(MainActivity.this);
//This is the part of url which will remain same in future request
String defaultURLPrefix = "https://www.yourdomain.com";
String request = "{\"username\": \"IntruderShanky\",\"password\": \"asd54fbg\"}";
builder.setCookieTag("Login Cookies");
builder.shouldDisplayDialog(true);
builder.setDialogMessage("Fetching Info");
builder.setDialogTitle("Loging In");
builder.shouldManageCookies(true);
builder.setConnectTimeOut(6000);
builder.setReadTimeOut(5500);
builder.setNetworkErrorMessage("Internet not connected");
builder.setDefaultURLPrefix(defaultURLPrefix);
//Create an instance of Milano, use this instance for future request
Milano milano = builder.build();
//Make HTTP request with customized request properties
milano.fromURL("/user_login")
.doPost(request)
.execute(new OnRequestComplete() {
@Override
public void onSuccess(String response, int responseCode) {
//Do whatever you want to do
addText("\nResponse: " + response);
}
@Override
public void onError(String error, int errorCode) {
//Do whatever you want to do
addText("\nError: " + error);
}
});
Add these lines to your progaurd file for release build.
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** w(...);
public static *** v(...);
public static *** i(...);
}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.