Getting Started

Mego Coin is a module of MegoGrid. Here, I’ll explain what Mego Coin 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, there are certain features in their applications to which they want to restrict 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 Coin.

Mego Coin Demo is an app which demonstrates how we’ve used our Mego Coin 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 Coin. 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 in addition to processing your own app’s data.

It’s for this reason that we’ve introduced our Mego Coin module—to help developers save time. We worry about developing this sort of functionality so that they can concentrate on their app development.

This module has three types of feature purchase system which have been integared in this demo application. This Demo app will show you how such purchase system works. All the purchase types are desribed 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, call our MeCoin Module main class MePurchaseManager as shown in the below code snippet.

MePurchaseManager purchaseManager = new MePurchaseManager(SplashActivity.this);

Once you’ve configured these, you’re ready to call our Mego Coin 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 they click on the credit buttons, a prompt will appear indicating that it’s a permanent purchase type. After unlocking they feature, they can use it forever. To integrate this purchase module, call the MePurchaseManager’s getIdStatus() method at the point in your code that allow access to the feature. This method involves three parameters:

Please note that you must initiate the MePurchaseManager class in each activity or class where you want such validations in your application. Below is the code snippet which demonstrates how we integrated this validation with 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 time period once users unlock or purchase it. Once the specified period is over, the feature will be locked again. For implementation, please reference 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