Skip to content

Integration

Using the Kitaboo SDK and the Kitaboo reader, you can have a fully functional reader that is equivalent to the white-labeled version of the Kitaboo reader in four simple steps.

Note

If you have already integrated the reader with your app, you can also customize it, as explained here.

The subsequent sections include the steps to integrate the reader into your App :

1. Add the Kitaboo SDK and its dependencies

  • Add the Kitaboo SDK AAR file as a library module in your project.
  • Add the following codeline in your Module gradle and sync the file to use the Kitaboo SDK.
compile project(':sdk')
  • To add the supporting dependencies, include the following code snippet :
compile 'com.android.support:design:25.3.1'
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
compile 'com.android.volley:volley:1.0.0'
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.2-3'
compile 'io.reactivex.rxjava2:rxjava:2.0.6'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

2. Initialize the Kitaboo SDK from your app’s Launcher Activity

Include the code snippet given below :

// For sampleApplication, "MainActivity" is the Launcher Activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
// Initialization of kitabooSDK
KitabooSDK.initializeSDK(this.getApplication(), CLIENT_ID)                 
}

Where,

  • CLIENT_ID is the unique id of the client that identifies the customer
  • this.getApplication() is the Application context.

3. Integrate the Kitaboo Reader

At this point in the integration process, the SDK is integrated and ready to be used. You will find the Kitaboo reader in the SDK package, which is the reader shell that uses the SDK to create the entire reader experience.

To add this activity in your app, copy the Kitaboo reader activity file, PlayerActivity.java from our SDK zip into your app project folder, which includes all your activity files.

4. Reader Integration

  • To specify the layout in which a book from the bookshelf will be opened, add the code given below in the Reader Activity XML file.
<FrameLayout
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    <fragment
        android:id="@+id/custom_layout"
        class="com.hurix.renderer.RendererView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></fragment>
</FrameLayout>

Note

RendererView is a class exposed by Kitaboo SDK which renders the content based on the content type - KitabooFixed [pdf version] , EpubFixed or EpubReflowable. This will take input as a path of content/book and create their respective view accordingly. This view consists of both the Reader shell and the content.

  • To invoke the SDK to render the selected content, include the code given below in the book click event listener.
// This /**
 *  Function responsible to invoke the BookPlayer.
 * @param path Path of the Book.
 * @param bookid Id of the Book.
 */

private void openPlayer(String path, long bookid, IBook clickedBook)
 {
    Intent subActivity = new Intent(mContext, PlayerActivity.class);
    ((Activity) mContext).startActivityForResult(subActivity, Constants.BOOKPLAYER_REQUEST_CODE);
}Intent subActivity = new Intent(getApplicationContext(), PlayerActivity.class);
subActivity.putExtra("media_path", path);
subActivity.putExtra("isEncrypt",clickedBook.isBookEncrypt());
subActivity.putExtra("ISBN",  clickedBook.getBookISBN());
subActivity.putExtra("classAssociated",clickedBook.IsClassAssociated());
subActivity.putExtra("classID",clickedBook.getClassList().get(0).getID());
subActivity.putExtra("book_id", bookid);
subActivity.putExtra("userID", mUserId);
subActivity.putExtra("token", mUserToken);
subActivity.putExtra("version", mCurrentSelectedBook.getUpdatedBookVersion());
subActivity.putExtra("Rolename", mRoleName);
subActivity.putExtra("lastPageSync", "1");

              startActivityForResult(subActivity, Constants.BOOKPLAYER_REQUEST_CODE);
  • Parameter description :
Key Value and description Mandatory
media_path Value: path

Description: Represents the location where the content/book is stored

Yes
isEncrypt Value: clickedBook.isBookEncrypt()

Description: Returns true if the book is encrypted, false if it is not

Yes
ISBN Value: clickedBook.getBookISBN()

Description: Value of type long that comes with the book

Yes
classAssociated Value: clickedBook.IsClassAssociated()

Description: Returns true if the content / book is associated with the class, false if it is not

No
classID Value: clickedBook.getClassList().get(0).getID()

Description: Represents the ID of the associated class

No
book_id Value: bookid

Description: Value of type long that represents the content / book ID

Yes
userID Value: mUserId Description: Value of type long that represents a user’s unique ID Yes
token Value: mUserToken Description: Value of type String, received after successful login Yes
version Value: clickedBook.getUpdatedBookVersion()

Description: Value of type long that returns the updated version of the book

Yes
Rolename Value: mRoleName Description: Represents the user role (learner or instructor), received with the value in login response No
lastPageSync Value:

Description: Represents the last page visited for a particular book

No

AudioBook - Coming soon

AudioBook will be available soon in SDK.

Interface to launch AudioBook that can be customized and modified to meet the specific business requirements.

Video Player - Coming soon

Video Player will be available soon in SDK.

Interface to launch Video player that can be customized and modified to meet the specific business requirements.