Steps to integrate Patch Framework SDK to Android app

  1. Create a new app in Quixxi Portal using " Add New button" button.
  2. In "Create Your App" dialog enter the name of the application and click Continue.
  3. Click the newly created app and choose " Control" in header tab and choose Package in left side menu.
  4. Click "Add Platform" button and choose "Android" and check "Patch" in Select module options.
  5. Give proper package name for the application and click "Start Packaging" button.
  6. Choose "Patcher" in  Subscription options.
  7. Now Quixxi will pack both Analytics and Patch framework and notify once it gets completed.
  8. Click "Download library" to get the library. You will receive a package which contains a patch library called “QuixxiLibrary.aar” and Android studio plugin “QuixxiPlugin.jar”.
  9. NOTE: Quixxi Patch supports only from Android API 19 to latest.So set your minsdk of application 19 or later.Also use the latest version of Android Studio IDE.
  10. Currently, Quixxi Patch supports Android applications developed in Java, Kotlin support will be rolled out soon.


Let’s see how to integrate Quixxi Library to the application

  1. To integrate the library(QuixxiLibrary.aar) with the application using Android Studio, Goto File -> New Module -> Choose Import .JAR/.AAR package and click Next.

  2. Choose the extracted Quixxi Framework SDK(QuixxiLibrary.aar), change subproject name if necessary and click “Finish".

  3. Open your application module's build.gradle file and add  the following line in "dependencies"
     compile project(':QuixxiLibrary')

  4. Also add following latest google play services dependency in the same build.gradle
    compile 'com.google.android.gms:play-services:11.0.4'

  5. Click "Sync Project" to add QuixxiLibrary as your application dependency.

  6. Initialize Quixxi Patch in  OnCreate() of your Application class like following

    <span style="font-size: 16px;">QuixxiPatch.isDebug = true; //true for "Debug" build and false for "Release" build
    QuixxiPatch qp = new QuixxiPatch(MainApplication.this);
    qp.init("your_app_version_name"); </span>



  7. Add the below permissions in your Manifest.xml
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     


     
  8. To track the location of a user add the permissions mentioned below
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>


Runtime Permissions


If your app is targeting Marshmallow (targetSdkVersion of 23 or higher), you need to request permissions at runtime.
We need Contacts(android.permission.GET_ACCOUNTS)  for Quixxi Patch.We recommend showing the user an explanation before presenting the permission prompt.

Following is the sample of requesting CONTACTS permissions at runtime


  1. Create a unique code for the permission in the Activity 
    <span style="font-size: 16px;">private static final int REQUEST_CONTACT_PERMISSION = 100;</span><span style="font-size: 16px;">
    </span>


  2. Check for the permission if granted already or request for the permission
    <span style="font-size: 16px;">if (ActivityCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS)
        != PackageManager.PERMISSION_GRANTED) {
      ActivityCompat.requestPermissions(this,
          new String[] {Manifest.permission.GET_ACCOUNTS},
          REQUEST_CONTACT_PERMISSION
      );
    }</span>


  3. Handle the permissions request in your Activity like follows:
    <span style="font-size: 16px;">@Override
    public void onRequestPermissionsResult(
        int requestCode,
        @NonNull String[] permissions,
        @NonNull int[] grantResults) {
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    
      switch (requestCode) {
          case REQUEST_CONTACT_PERMISSION:
            if (permissions.length > 0 &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; permissions[0].equals(Manifest.permission.GET_ACCOUNTS)
                  &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                  
              QuixxiPatch.isDebug = true;
              QuixxiPatch qp = new QuixxiPatch(MainApplication.this);
              qp.init("app_version_name");
    
            } else {
              // Show an explanation toast 
              Toast.makeText(this, "The app needs contacts permissions to continue.", Toast.LENGTH_LONG).show();
            }
            break;
      }
    }</span>


    If you are not familiar with "Runtime Permissions" then please refer this simplified wrapper library EasyPermissions and Android Development document here.