Android

API client library
Getting started
Install

Step 1. Add the JitPack repository to your build file


                      allprojects {
                        repositories {
                            ...
                            maven { url 'https://jitpack.io' }
                        }
                     }
                    

Step 2. Add the dependency


                      dependencies {
                        implementation 'com.github.plentra:sphereclient:1.0.4'
                }
                    

Initialization


                      ...
                      import com.plentra.sphereclient.SphereClient;
                      ...
                      
                      SphereClient sphereclient;
                      
                      class YOUR_CLASS_NAME extends PARENT_CLASS { 
                      ...
                          sphereClient = new SphereClient("YOUR_APP_KEY")
                      
                      
                      }
                          
                    

Get Home Launcher (with launcher items)

Home launcher is the main launcher of your app containing launcher items that link to either items belonging to a particular category or a sub launcher.It also acts as a source for special features such as popup and message (It is intended to launch during the initial launch of your application).

Accessing the home launcher

You can access home launcher properties by calling getHome method on the sphereClient object.The getHome method has single argument that accepts GetHome interface.


                      sphereClient.getHome(new GetHome() {

                        @Override
                        public void onResult(String appName, String appIcon, int totalItemCount, int itemsInThisPage, int itemsPerPage, HomeItems[] items) {
                        //do on result
                        }
                    
                        @Override
                        public void onLoading() {
                        //do when loading
                        }
                    
                        @Override
                        public void onLoadfinished() {
                        //do when loading finished
                        }
                    
                        @Override
                        public void onPopup(String popupTitle , String popupBody) {
                        //do when popup
                        }
                    
                        @Override
                        public void onAnnouncement( String announcementBody) {
                        //do when announcement
                        }
                    
                        @Override
                        public void onMessage(String messageTitle , String messageBody) {
                        //do when message
                        }
                    
                        @Override
                        public void onAppLocation(String appLocation, double latitude, double longitude) {
                        //do when app location
                        }
                    
                        @Override
                        public void onNextPage() {
                        //do when next page exists
                        }
                    
                        @Override
                        public void onHomeCover(String cover) {
                        //do when there is a home cover
                        }
                    
                        @Override
                        public void onEmpty(String appName, String appIcon) {
                        //do when home launcher items are empty
                        }
                    
                        @Override
                        public void onError(VolleyError error) {
                        //do when error
                        }
                    
                        @Override
                        public void onUnderConstruction() {
                        //do when under construction
                        }
                    
                        @Override
                        public void onNotActive() {
                        //do when app is not active
                        }
                    
                        @Override
                        public void onNotExist() {
                        //do when app does not exist
                        }
                    
                        @Override
                        public void onNotFound() {
                        //do when page not found
                        }
                    
                        @Override
                        public void onNotAcceptable() {
                        //do when there is illegal client request
                        }
                    
                        @Override
                        public void onBadRequest() {
                        //do when there is bad request from client
                        }
                    
                        @Override
                        public void onNoNextPage() {
                        //do when there is no next page
                        }
                     });
                    
                    
GetHome interface methods
Methods description
onResult(String appName , String appIcon , int totalItemCount , int itemsInThisPage , int itemsPerPage , HomeItems[] items) This method provides App's name,icon,total number of items available in home launcher, number of items available in current page , max number of items that can be available in current page and array of items as HomeItems instance (This method is called only when home launcher items are available).
onLoading() This method is called when the library is fetching the data from the servers (You can display a loading screen on this method call).
onLoadfinished() This method is called when the library has successfully fetched the data from the servers (You can stop displaying the loading screen on this method call).
onPopup(String popupTitle , String popupBody) This method is called when there is a popup enabled in your app.It provides the popup title and popup body.
onAnnouncement(String announcementBody) This method is called when there is announcement enabled in your app.It provides the announcemment body.
onMessage(String messageTitle , String messageBody) This method is called when there is a message enabled in your app.It provides the message title and message body.
onAppLocation(String appLocation, double latitude, double longitude) This method is called when business location is available in your app.It provides app's location , latitude and longitude.
onNextPage() This method is called when next page is available so that the home launcher items available in the next page can be loaded.
onHomeCover(String cover) This method is called when cover is available for the home launcher.
onEmpty(String appName, String appIcon) This method is called when there are no home launcher items.This provides app's name and icon.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.
onNoNextPage() This method is called when next page is not available.
Accessing more home launcher items

You can access home launcher properties by calling getLauncherLoadMore method on the sphereClient object.The getHomeLoadMore method has single argument that accepts GetHomeLoadMore interface.



sphereClient.getHomeLoadMore(new GetHomeLoadMore() {

  @Override
  public void onResult(int totalItemCount, int itemsInThisPage, int itemsPerPage, HomeItems[] items) {
  //do on result
  }

  @Override
  public void onLoading() {
  //do when loading
  }

  @Override
  public void onLoadfinished() {
  //do when loading finished
  }

  @Override
  public void onNextPage() {
  //do when next page exists
  }

  @Override
  public void onEmpty() {
  //do when home launcher items are empty
  }

  @Override
  public void onError(VolleyError error) {
  //do when error
  }

  @Override
  public void onUnderConstruction() {
  //do when under construction
  }

  @Override
  public void onNotActive() {
  //do when app is not active
  }

  @Override
  public void onNotExist() {
  //do when app does not exist
  }

  @Override
  public void onNotFound() {
  //do when page not found
  }

  @Override
  public void onNotAcceptable() {
  //do when there is illegal client request
  }

  @Override
  public void onBadRequest() {
  //do when there is bad request from client
  }

  @Override
  public void onNoNextPage() {
  //do when there is no next page
  }
});

                  
GetHomeLoadMore interface methods
Methods description
onResult(int totalItemCount , int itemsInThisPage , int itemsPerPage , HomeItems[] items) This method provides total number of items available in this page, number of items available in current page , max number of items that can be available in current page and array of items as HomeItems instance (This method is called only when home launcher items are available).
onLoading() This method is called when the library is fetching the data from the servers (You can display load more progress bar on this method call).
onLoadfinished() This method is called when the library has successfully fetched the data from the servers (You can stop displaying the progress bar on this method call).
onNextPage() This method is called when next page is available so that the home launcher items available in the next page can be loaded.
onEmpty() This method is called when there are no home launcher items in this page.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.
onNoNextPage() This method is called when next page is not available.

Get items belonging to a category

Every item you add is linked to a category.

Accessing the items belonging to a category

You can access all the items belonging to a category by calling getItems method on the sphereClient object.The getItems method has two arguments that accepts getItems interface and item category id .


                    sphereClient.GetItems(new GetItems() {

                      @Override
                      public void onResult(String appName, String appIcon, String categoryName, String categoryIcon, int totalItemCount, int itemsInThisPage, int itemsPerPage, Items[] items) {
                      //do on result
                      }
                  
                      @Override
                      public void onLoading() {
                      //do when loading
                      }
                  
                      @Override
                      public void onLoadfinished() {
                      //do when loading finished
                      }
                  
                      @Override
                      public void onAnnouncement( String announcementBody) {
                      //do when announcement
                      }
                  
                      @Override
                      public void onAppLocation(String appLocation, double latitude, double longitude) {
                      //do when app location
                      }
                  
                      @Override
                      public void onNextPage() {
                      //do when next page exists
                      }
                  
                      @Override
                      public void onHomeCover(String cover) {
                      //do when there is a home cover
                      }
                  
                      @Override
                      public void onEmpty(String appName, String appIcon, String categoryName, String categoryIcon) {
                      //do when items are empty
                      }
                  
                      @Override
                      public void onError(VolleyError error) {
                      //do when error
                      }
                  
                      @Override
                      public void onUnderConstruction() {
                      //do when under construction
                      }
                  
                      @Override
                      public void onNotActive() {
                      //do when app is not active
                      }
                  
                      @Override
                      public void onNotExist() {
                      //do when app does not exist
                      }
                  
                      @Override
                      public void onNotFound() {
                      //do when page not found
                      }
                  
                      @Override
                      public void onNotAcceptable() {
                      //do when there is illegal client request
                      }
                  
                      @Override
                      public void onBadRequest() {
                      //do when there is bad request from client
                      }
                  
                      @Override
                      public void onNoNextPage() {
                      //do when there is no next page
                      }
                   });
                  
GetItems interface methods
Methods description
onResult(String appName, String appIcon, String categoryName, String categoryIcon, int totalItemCount, int itemsInThisPage, int itemsPerPage, Items[] items) This method provides App's name,icon ,category name,category icon,total number of items available in the current page, number of items available , max number of items that can be available in current page and array of items as Items instance (This method is called only when items belonging to this category are available in this page ).
onLoading() This method is called when the library is fetching the data from the servers (You can display a loading screen on this method call).
onLoadfinished() This method is called when the library has successfully fetched the data from the servers (You can stop displaying the loading screen on this method call).
onAnnouncement(String announcementBody) This method is called when there is announcement enabled in your app.It provides the announcemment body.
onAppLocation(String appLocation, double latitude, double longitude) This method is called when business location is available in your app.It provides app's location , latitude and longitude.
onNextPage() This method is called when next page is available so that the items available in the next page can be loaded.
onHomeCover(String cover) This method is called when cover is available.
onEmpty(String appName, String appIcon) This method is called when there are no home launcher items.This provides app's name and icon.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.
onNoNextPage() This method is called when next page is not available.
Accessing more items belonging to a category

You can access more items belonging to a category by calling getItemsLoadMore method on the sphereClient object.This iterates the next page available and loads the properties of that page everytime this method is called.The getItemsLoadMore method has two arguments that accepts GetItemsLoadMore interface and category id.



sphereClient.GetItemsLoadMore(new GetItemsLoadMore() {

  @Override
  public void onResult(int totalItemCount, int itemsInThisPage, int itemsPerPage, Items[] items) {
  //do on result
  }

  @Override
  public void onLoading() {
  //do when loading
  }

  @Override
  public void onLoadfinished() {
  //do when loading finished
  }

  @Override
  public void onNextPage() {
  //do when next page exists
  }


  @Override
  public void onEmpty() {
  //do when items are empty
  }

  @Override
  public void onError(VolleyError error) {
  //do when error
  }

  @Override
  public void onUnderConstruction() {
  //do when under construction
  }

  @Override
  public void onNotActive() {
  //do when app is not active
  }

  @Override
  public void onNotExist() {
  //do when app does not exist
  }

  @Override
  public void onNotFound() {
  //do when page not found
  }

  @Override
  public void onNotAcceptable() {
  //do when there is illegal client request
  }

  @Override
  public void onBadRequest() {
  //do when there is bad request from client
  }

  @Override
  public void onNoNextPage() {
  //do when there is no next page
  }
});
                  
GetItemsLoadMore interface methods
Methods description
onResult(int totalItemCount, int itemsInThisPage, int itemsPerPage, Items[] items) This method provides total number of items available in the current page, number of items available , max number of items that can be available in current page and array of items as Items instance (This method is called only when items are available in the page).
onLoading() This method is called when the library is fetching the data from the servers (You can display a progress bar on this method call).
onLoadFinished() This method is called when the library has successfully fetched data from the servers (You can stop displaying the progress bar on this method call).
onNextPage() This method is called when next page is available so that the items available in the next page can be loaded.
onEmpty() This method is called when there are no home launcher items.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.
onNoNextPage() This method is called when next page is not available.

Get Sub launcher

Just like the home launcher the sub launcher contains launcher items that are linked either to a category or other sub launcher.

Accessing the sub launcher

You can access all the properties of sub launcher by calling getLauncher method on the sphereClient object.The getLauncher method has two arguments that accepts getLauncher interface and launcher id



sphereClient.GetLauncher(new GetLauncher() {

  @Override
  public void onResult(String appName, String appIcon, String launcherName, String launcherIcon, int totalItemCount, int itemsInThisPage, int itemsPerPage, LauncherItems[] items) {
  //do on result
  }

  @Override
  public void onLoading() {
  //do when loading
  }

  @Override
  public void onLoadfinished() {
  //do when loading finished
  }

  @Override
  public void onAnnouncement( String announcementBody) {
  //do when announcement
  }

  @Override
  public void onAppLocation(String appLocation, double latitude, double longitude) {
  //do when app location
  }

  @Override
  public void onNextPage() {
  //do when next page exists
  }

  @Override
  public void onLauncherCover(String cover) {
  //do when there is launcher cover
  }

  @Override
  public void onEmpty(String appName, String appIcon, String launcherName, String launcherIcon) {
  //do when launcher items are empty
  }

  @Override
  public void onError(VolleyError error) {
  //do when error
  }

  @Override
  public void onUnderConstruction() {
  //do when under construction
  }

  @Override
  public void onNotActive() {
  //do when app is not active
  }

  @Override
  public void onNotExist() {
  //do when app does not exist
  }

  @Override
  public void onNotFound() {
  //do when page not found
  }

  @Override
  public void onNotAcceptable() {
  //do when there is illegal client request
  }

  @Override
  public void onBadRequest() {
  //do when there is bad request from client
  }

  @Override
  public void onNoNextPage() {
  //do when there is no next page
  }
});

                  
GetLauncher interface methods
Methods description
onResult(String appName, String appIcon, String launcherName, String launcherIcon, int totalItemCount, int itemsInThisPage, int itemsPerPage, LauncherItems[] items) This method provides App's name,icon ,launcher name,launcher icon,total number of launcher items available in the current page, number of launcher items available , max number of launcher items that can be available in current page and array of launcher items as LauncherItems instance (This method is called only when launcher items are available in this page).
onLoading() This method is called when the library is fetching the data from the servers (You can display a loading screen on this method call).
onLoadfinished() This method is called when the library has successfully fetched the data from the servers (You can stop displaying the loading screen on this method call).
onAnnouncement(String announcementBody) This method is called when there is announcement enabled in your app.It provides the announcemment body.
onAppLocation(String appLocation, double latitude, double longitude) This method is called when business location is available in your app.It provides app's location , latitude and longitude.
onNextPage() This method is called when next page is available so that the items available in the next page can be loaded.
onLauncherCover(String cover) This method is called when launcher cover is available.
onEmpty(String appName, String appIcon, String launcherName, String launcherIcon) This method is called when there are no launcher items.This provides app's name,icon,launcher name and launcher icon.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.
onNoNextPage() This method is called when next page is not available.
Accessing more sub launcher items

You can access more sub launcher items by calling getLauncherLoadMore method on the sphereClient object.This iterates the next page available and loads the properties of that page everytime this method is called.The getLauncherLoadMore method has two arguments that accepts GetLauncherLoadMore interface and launcher id.



sphereClient.GetLauncherLoadMore(new GetLauncherLoadMore() {

  @Override
  public void onResult(int totalItemCount, int itemsInThisPage, int itemsPerPage, LauncherItems[] items) {
  //do on result
  }

  @Override
  public void onLoading() {
  //do when loading
  }

  @Override
  public void onLoadfinished() {
  //do when loading finished
  }

  @Override
  public void onNextPage() {
  //do when next page exists
  }

  @Override
  public void onEmpty() {
  //do when launcher items are empty
  }

  @Override
  public void onError(VolleyError error) {
  //do when error
  }

  @Override
  public void onUnderConstruction() {
  //do when under construction
  }

  @Override
  public void onNotActive() {
  //do when app is not active
  }

  @Override
  public void onNotExist() {
  //do when app does not exist
  }

  @Override
  public void onNotFound() {
  //do when page not found
  }

  @Override
  public void onNotAcceptable() {
  //do when there is illegal client request
  }

  @Override
  public void onBadRequest() {
  //do when there is bad request from client
  }

  @Override
  public void onNoNextPage() {
  //do when there is no next page
  }
});

                
GetLauncherLoadMore interface methods
Methods description
onResult(int totalItemCount, int itemsInThisPage, int itemsPerPage, LauncherItems[] items) This method provides total number of launcher items available in the current page, number of launcher items available , max number of launcher items that can be available in current page and array of launcher items as LauncherItems instance (This method is called only when launcher items are available in this page).
onLoading() This method is called when the library is fetching the data from the servers (You can display a progress bar on this method call).
onLoadfinished() This method is called when the library has successfully fetched the data from the servers (You can stop displaying the progress bar on this method call).
onNextPage() This method is called when next page is available so that the items available in the next page can be loaded.
onEmpty() This method is called when there are no launcher items.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.
onNoNextPage() This method is called when next page is not available.

Get item

Accessing the item

You can access all the item properties by calling GetItem method on the sphereClient object.The GetItem method has two arguments that accepts getItem interface and item id.



sphereClient.GetItem(new GetItem() {

  @Override
  public void onResult(String appName, String appIcon, String itemName, JSONObject extras_, String body, String itemCategoryName, JSONObject itemImages_, String itemImage) {
  //do on result
  }

  @Override
  public void onLoading() {
  //do when loading
  }

  @Override
  public void onLoadfinished() {
  //do when loading finished
  }

  @Override
  public void onAnnouncement( String announcementBody) {
  //do when announcement
  }

  @Override
  public void onAppLocation(String appLocation, double latitude, double longitude) {
  //do when app location
  }


  @Override
  public void onHomeCover(String cover) {
  //do when there is home cover
  }

  @Override
  public void onError(VolleyError error) {
  //do when error
  }

  @Override
  public void onUnderConstruction() {
  //do when under construction
  }

  @Override
  public void onNotActive() {
  //do when app is not active
  }

  @Override
  public void onNotExist() {
  //do when app does not exist
  }

  @Override
  public void onNotFound() {
  //do when page not found
  }

  @Override
  public void onNotAcceptable() {
  //do when there is illegal client request
  }

  @Override
  public void onBadRequest() {
  //do when there is bad request from client
  }

});
              
GetItem interface methods
Methods description
onResult(String appName, String appIcon, String itemName, JSONObject extras_, String body, String itemCategoryName, JSONObject itemImages_, String itemImage) This method provides App's name,icon ,item name,item extras,item body,item's category name,item gallery images and item image.
onLoading() This method is called when the library is fetching the data from the servers (You can display a loading screen on this method call).
onLoadfinished() This method is called when the library has successfully fetched the data from the servers (You can stop displaying the loading screen on this method call).
onAnnouncement(String announcementBody) This method is called when there is announcement enabled in your app.It provides the announcemment body.
onAppLocation(String appLocation, double latitude, double longitude) This method is called when business location is available in your app.It provides app's location , latitude and longitude.
onHomeCover(String cover) This method is called when home cover is available.
onError(VolleyError error) This method is called when an error has occured in the internal volley library used for fetching the data such as a network error.
onUnderConstruction() This method is called when the under construction mode is enabled in the app.
onNotActive() This method is called when your app is not active due to subscription expiration.
onNotExist() This method is called when your app is removed or is temporarily banned.
onNotFound() This method is called when home launcher or current page is not available.
onNotAcceptable() This method is called when there is illegal client request.
onBadRequest() This method is called when there is a bad request from client.

Contact us

You can reach us any time

mail
Email

Write an email to

[email protected]

smartphone
Phone

Mon - Fri 09:00 - 18:00

+91 9429693099

Copyright Ⓒ 2023 Plentra Technologies Pvt Ltd