UmUtils得到友盟的渠道号

Posted 码上加油站

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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得到友盟的渠道号的主要内容,如果未能解决你的问题,请参考以下文章