Skip to content

Import pataa_sdk.aar file in lib folder

androidsdk

Add dependencies in app.gradle

implementation project(':pataa_autofill_sdk')
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

Add Metadata in manifest

<meta-data
   android:name="pataa.autofill.sdk.ClientKey"
   android:value="@string/PATAA_API_KEY" />

<meta-data
   android:name="pataa.autofill.sdk.EnableLogger"
   android:value="true" /> 

Add widget in xml(do not change the id(vPataaCodeView))

<com.pataa.sdk.PataaAutoFillView
   android:id="@+id/vPataaCodeView"
   android:layout_width="match_parent"
   android:layout_height="match_parent" /> 

Create a object in activity

PataaAutoFillView pataaAddress;

Initialize the object

pataaAddress = findViewById(com.pataa.sdk.R.id.vPataaCodeView);

Set properties and listener

pataaAddress
       .setCurrentActivity(this)//to get the result of create pataa
       .setAddressCallBack(new OnAddress() {//to get the click events
           @Override
           public void onNetworkIsNotAvailable() {
               Toast.makeText(MainActivity.this, "onNetworkIsNotAvailable", Toast.LENGTH_SHORT).show();
           }

           @Override
           public void onPataaNotFound(String message) {

           }

           @Override
           public void onPataaFound(GetPataaDetailResponse.User user, GetPataaDetailResponse.Pataa
                   response) {
               Toast.makeText(MainActivity.this, user.getFirst_name() + " : " + response.getFormattedAddress(), Toast.LENGTH_SHORT).show();
           }
       });

Add on activity result

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
   super.onActivityResult(requestCode, resultCode, data);

   if (requestCode == REQUEST_KEY_CREATE_PATAA && data != null && data.hasExtra(ON_ACT_RSLT_PATAA_DATA)) {
       String pc = data.getStringExtra(ON_ACT_RSLT_PATAA_DATA);
       if (pataaAddress != null) {
           pataaAddress.getPataadetail(pc);
       }
   }
}