Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

public class Main {
    /**
     *
     * Gets meta channel.
     *
     * @param activity    the activity
     * @param channelName just like "UMENG_CHANNEL"
     * @return meta channel
     */
    public static String getMetaChannel(Context activity, String channelName) {
        String channel = "";
        try {
            ApplicationInfo info = activity.getPackageManager().getApplicationInfo(activity.getPackageName(),
                    PackageManager.GET_META_DATA);
            channel = "" + info.metaData.get(channelName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //        Toast.makeText(activity, "channel is " + channel, Toast.LENGTH_LONG).show();
        return channel;

    }
}