-
Notifications
You must be signed in to change notification settings - Fork 12
##FAQ
####-The field xxx is null in processHttpResult or any other method even if I initialized it RestServerRequests implements parcelable. This means that the client class must implement writeToParcel and the Class(Parcelable) constructor. The field that must persist when the request is executed on the background thread must be written / read to the parcel. Check [Android Parcelable docs][parcelable] .
####-android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator Every parcelable requires a static CREATOR field even if not specified in the interface. Check [Android Parcelable docs][parcelable] .
####-The authentication dialog is stuck and does not close when the user logs in A callback url is required in order to intercept the redirect and fetch the oauth token. Some apis require to specify a callback url in the console. In some cases it might be any url, in others (facebook) must be of the same domain of the registered api. If not specified, the redirect won't happen and the library won't be able to fetch the oauth token.
####-How do I add parameters to the call? PostmanLib uses scribe java under the hood. Scribe requests allow to add query parameters / add body parameters.
public void addParamsToRequest(OAuthRequest request);
must be implemented.
public void addParamsToRequest(OAuthRequest request){
request.addQuerystringParameter("q", mName);
request.addQuerystringParameter("type", "user");
request.addBodyParameter("q", mName);
}
####-Does the lib support plain authentication? Since plain authentication consists in header parameter, it can be done implementing addParamsToRequest:
public void addParamsToRequest(OAuthRequest request){
request.addHeader("Authorization", "Basic "+Base64.encode(username+":"+password));
}
####-What if request b parameters depends on request a result? You can execute request b directly in request a's processHttpResult:
@Override
public void processHttpResult(Response result, RequestExecutor executor, Context context) throws ResultParseException {
// handle result
RequestB r = new RequestB(result); // depending on the result
executor.executeRequest(r, context); //<- executed immediately inside current thread
}
####-If your lib uses scribe under the hood, what's the need for a StorableServiceBuilder? Oh, I like this question :-) PostmanLib relies on a signleton object to perform it's logic. Due to the fact that in Android every resource might be reclaimed from the os, I had to store the registration details in some persistent way. StorableServiceBuilder just wraps Scribe's service builder and stores it in SharedPreferences.
####-Can I change parameter xxx of the request (or it's timeout, or yyyy) ? That's a job for
@Override
public void addParamsToRequest(OAuthRequest request) {
// do whatever you want to the request. It's just before sending it
}
####-Can I schedule periodic requests ? Mmmm. This means that you did not read carefully the main page. However, here's the answer. I did not like the idea of having an internal scheduling politic because that would result in wrapping alarm manager schedulings and try to cover all the possible cases that an advanced user could have in mind. One would like to reschedule the alarm less frequently in case of errors, or choose unexact repeating over exact repeating. For this reason (and for my lazyness) I decided to demand this to the final user of the library, providing a pendingintent to be scheduled. In short: call
PendingIntent i = helper.getActionToSchedule(context, "MyRequestID", myRequest);
and read the official AlarmManager documentation.