Getting Started

Mego Shop is a module of MegoGrid. Here I’ll explain what Mego Shop is and how it can help Android App Developers.

Modern mobile technology is becoming too vast for most people’s comfort. In keeping with the KISS principle, (Keep It Short and Simple), developers are doing their best to improve technology. Because their time is precious, they build frameworks to be more efficient. While developing applications, they have certain features for which they want to limit access. To get the maximum functionality, they often design a separate module along with the main application to do this.

Now, I’m sure everyone has further questions, so let’s start with the basics. Let’s cover the What, Why and How of Mego Shop.

Mego Shop Demo is an app which demonstrates how we’ve used our Mego Shop module to help developers concentrate on their main application development. The module frees them from the responsibility of creating their own modules to restrict user access to features before unlocking or buying them. Users will only be able to access features by unlocking or buying them via a credit system integrated with the application.

This tutorial is divided into several parts, each focusing on a different aspect of Mego Shop. Feel free to read them in any order, but we recommend that you download the source code and refer to it while reading. Some parts of the code were omitted in the interests of clarity, so you may find it useful to keep the full version close at hand.


As mobile application developers, we all know that there are certain features to which we want to give only limited access. For example, gaming applications have certain levels to play. If it’s a good game, there will be some initial levels available for free, but the higher levels will require some sort of payment. If you’ve already played the free levels and want to play the higher ones, you need a way to pay for them.

I know you’re confident you can make modules like these on your own. But consider how much time it will take. You’ll need to keep track of your app users, their application usage details, which features are unlocked for which user, how many days have passed since particular features were unlocked, etc.

It’s frustrating and time consuming to worry about these things while trying to simultaneously process your own app data.

It’s for this reason that we’ve introduced our Mego Shop module—to help developers save time. We worry about developing this sort of functionality so that they can concentrate on their app development. In this module we’ve used the Google Play services In-App Billing API, one of the most trusted methods for In-app purchases.

This module has three feature purchase systems, all of which have been integrated with this demo application. This Demo app will show you how the purchase systems work. All the purchase types are described below:

Before we explain the details of the above mentioned validation types, we need to adjust a few configuration settings on the application’s main activity onCreate() method. This demo app uses SplashActivity as its main activity. The two code snippets below demonstrate how we configure our Demo app. The first code snippet is used to authenticate user applications. It’s important that you call it first.

MegoAuthorizer megoAuthorizer = new MegoAuthorizer(SplashActivity.this);

After inputting the above code snippet, just call our MeShop Module main class MePurchaseManager as shown here.

MePurchaseManager purchaseManager = new MePurchaseManager(SplashActivity.this);

Because we’re using the Google Play Services purchasing API (In-app Billing), we need to set a Google License Key. You’ll get it from the Google Console when you configure your In-app products there. The key is a string value encoded with Base64.Call the setGoogleLicenceKey() method inside the onCreate() method of your application’s main activity and pass it like a base64Encoded key string value as an argument. Below is the code snippet which shows how we’ve set the license key in our demo application.


Once you’ve configured these, you’re ready to call our Mego Shop module API in your app. Use it in any section of code that you want executed for products or features already owned by the users-- otherwise users will get a purchase prompt. In this demo application we’ve shown how we’ve integrated this module. Below are the options for purchase types:


When users click on a premium feature, they’ll see a prompt which states, “This is a premium feature. Unlock to explore it!” Once they click the ‘buy’ button, they’ll be redirected to the feature purchase screen. On this screen, they’ll see feature details such as specs, credit requirements for purchase, child or sub-child features, etc. When he clicks on the price button, a prompt appears from Google Play API, indicating it’s a permanent feature-- after unlocking it you can use it forever. To integrate this purchase module, call the MePurchaseManager’s getIdStatus() method at the point of your code which allows access to that feature. There are three parameters for this method:

Please note you must initiate the MePurchaseManager class in each activity or class where you want this purchase mechanism in your application. Below is the code snippet showing how we integrated this into the demo application:

private void checkBoxStatus(String boxID, final String method_name){
        try {
        //here we have called the purchase method getIdStatus(), which will execute the
        //callTask() method if purchase is successful otherwise it will show the prompt to the user
            purchaseManager.getIDStatus(MainActivity.this, boxID, 0, new IFeatureClickable() {
                public void onFeatureClicked() {
        } catch (NoDataException e) {
        } catch (InvalidBoxIDException e) {
    //method to be called after successfull purchase
    private void callTask(String mName){
        try {
            Method method = getClass().getDeclaredMethod(mName);
            method.invoke(thisnew Object[]{});
        } catch (Exception e)


Partial purchase means a feature will be active for a certain period of time once a user unlocks or purchases it. Once the specified period is over, the feature will be locked again. For implementation, please refer to the Permanent purchase section described above.


Use this to create a subscription plan for your app features. Buyers will get access to your app the same way they’d subscribe to a newspaper or pay monthly bills for their cable TV. Subscription plans involve paying a fixed amount of money at regular intervals. They’re the third type of purchasing option you can use for your app.

Once users unlock a feature which is subscription-based, they’ll be charged on a regular basis. They’ll have access to the feature until they send an unsubscribe request.

If they send an unsubscribe request, they’ll have access until their plan expires. For implementation, please refer to the Permanent purchase section above.

© 2015-2016 Megogrid Inc. / Term of service / Licenses / Privacy Policy 913 N Market Street Suite 200 Wilmington DE 19801 USA