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 "";
      }
   }
}

 

posted on 2017-02-23 19:55  LoaderMan  阅读(466)  评论(0编辑  收藏  举报

导航