首页 > 代码库 > UmUtils得到友盟的渠道号

UmUtils得到友盟的渠道号

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;

public class UmUtils {
   /**
    * 得到友盟的渠道号
    */
   public static String getUmMetaInfo(Context context) {
      try {
         ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
         Bundle bundle = ai.metaData;
         return bundle.getString("UMENG_CHANNEL");
      } catch (NameNotFoundException e) {
         e.printStackTrace();
         return "";
      }
   }
}

 

UmUtils得到友盟的渠道号