小编use*_*543的帖子

如何以编程方式在Android中获取广告ID

我想以编程方式获取用户广告ID.我使用了以下开发者网站的代码.但它不起作用

         Info adInfo = null;
          try {
            adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());

          } catch (IOException e) {
            // Unrecoverable error connecting to Google Play services (e.g.,
            // the old version of the service doesn't support getting AdvertisingId).

          } catch (GooglePlayServicesNotAvailableException e) {
            // Google Play services is not available entirely.
          } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (GooglePlayServicesRepairableException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
          final String id = adInfo.getId();
          final boolean isLAT = …
Run Code Online (Sandbox Code Playgroud)

android

30
推荐指数
7
解决办法
5万
查看次数

标签 统计

android ×1