This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
developers:peig-api:android [2016/10/26 08:18] 127.0.0.1 external edit |
developers:peig-api:android [2019/08/01 10:02] tjotov removed |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Developing Android application with ADUCID ====== | ====== Developing Android application with ADUCID ====== | ||
- | |||
- | //See [[https:// | ||
- | |||
Prerequisites: | Prerequisites: | ||
Line 12: | Line 9: | ||
===== Creating authentication request ===== | ===== Creating authentication request ===== | ||
- | - First create an instance of PEIG API \\ (only one per application / set of requests) | + | 1) First create an instance of PEIG API \\ (only one per application |
- | - Prepare a handler which is going to be called when PEIG API is finished | + | <code java> |
- | - Call PEIG API method aducidAuthentication | + | com.aducid.peig.api.Papi papi = new com.aducid.peig.api.Papi(android.content.Context ctx) |
+ | com.aducid.peig.lib2.PeigAPI peigApi = new com.aducid.peig.lib2.PeigAPI(android.content.Context ctx) | ||
+ | </ | ||
+ | |||
+ | or create DummyApplication | ||
<code java> | <code java> | ||
- | aducidAuthentication(String url, Handler handler) | + | public class DummyApplication extends com.aducid.peig.lib2.PeigAPILibApplication { |
+ | protected com.aducid.peig.api.Papi papi; | ||
+ | protected com.aducid.peig.lib2.PeigAPI peigApi; | ||
+ | |||
+ | public DummyApplication() { | ||
+ | | ||
+ | papi = getPapi(); | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 2) Prepare a handler which is going to be called when PEIG API is finished (see below) | ||
+ | |||
+ | 3) Call PEIG API method aducidAuthentication (): | ||
+ | |||
+ | <code java> | ||
+ | peigApi.aducidAuthentication(java.lang.String url, android.os.Handler handler) | ||
</ | </ | ||
* **url** | * **url** | ||
* **handler** | * **handler** | ||
- | In your Handler override **handleMessage** | + | |
+ | 4) In your Handler override **handleMessage** | ||
<code java> | <code java> | ||
- | PapiResult | + | com.aducid.peig.lib2.Result |
</ | </ | ||
Line 42: | Line 62: | ||
Your session is authenticated | Your session is authenticated | ||
- | In DemoBank, result.gerRedirect() contains link to page with account data | + | In DemoBank, result.gerRedirect() contains link to page with account data. Method result.containsRedirectUri() returns //true//, if redirect contains some link. |
II. | II. | ||
Line 53: | Line 73: | ||
< | < | ||
- | getPapi().installPEIG(getActivity()); | + | papi.installPEIG(getActivity()); |
</ | </ | ||
Line 75: | Line 95: | ||
* result.notAcceptedByUser(): | * result.notAcceptedByUser(): | ||
* result.isFactorAbsent(): | * result.isFactorAbsent(): | ||
- | * result.getData() contains error Message | + | * result.getData() contains error message |
* result.getRedirect() contains page that could be opened using browser / contains additional content to download/ display to the user. | * result.getRedirect() contains page that could be opened using browser / contains additional content to download/ display to the user. | ||
- | //See PapiResult | + | //See com.aducid.peig.lib2.Result |
===== Retrieve data when authenticated ===== | ===== Retrieve data when authenticated ===== | ||
Line 85: | Line 105: | ||
< | < | ||
- | getPapi().getAsyncClient().get(String url, RequestParams parameters, ResponseHandlerInterface responseHandler) | + | peigApi.aducidContent(java.lang.String url, java.lang.String methodName, android.os.Handler handler) |
</ | </ | ||
- | * **url** | + | * **url** |
- | * **parameters** – specify https(s) request parameters for your request if needed | + | * **methodName** - method path, e.g. / |
- | * **AsyncHttpResponseHandler** – callback to be executed when data is loaded | + | * **handler** – Android |
==== Try to get data if not authenticated ==== | ==== Try to get data if not authenticated ==== | ||
Line 97: | Line 117: | ||
===== Advanced requests ===== | ===== Advanced requests ===== | ||
- | To accomplish a specific action like transaction use aducidFullOperation() | + | To accomplish a specific action like transaction use aducidFullOperationGet() or aducidFullOperationPost(). |
- | See DemoBank PaymentFragment.java example | ||
<code java> | <code java> | ||
- | aducidFullOperationPost(String url, String methodName,RequestParamsparameters, Handler handler) | + | peigApi.aducidFullOperationPost(String url, String methodName, |
</ | </ | ||
Line 112: | Line 131: | ||
<code java> | <code java> | ||
- | PapiResult | + | Handler handler = new Handler() { |
+ | @Override | ||
+ | public void handleMessage(Message msg) { | ||
+ | |||
+ | if (msg.getData() != null) { | ||
+ | com.aducid.peig.lib2.Result | ||
+ | // do something with result | ||
+ | } | ||
+ | } | ||
+ | } | ||
</ | </ | ||