title: How to get Advertising id in android?
body: <blockquote>
    <p>I used this code it's working when i called from activity and fragment  </p>
  </blockquote>
  
  <pre><code>import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
  
  
  Info adInfo = null;
  
  try {
       adInfo = AdvertisingIdClient.getAdvertisingIdInfo(mContext);
  } catch (IOException e) {
       e.printStackTrace();
  } catch (GooglePlayServicesAvailabilityException e) {
       e.printStackTrace();
  } catch (GooglePlayServicesNotAvailableException e) {
       e.printStackTrace();
  }
  
  String AdId = adInfo.getId();
  </code></pre>
  
  <blockquote>
    <p>But when i called from pending intent like Package Removed then i want to call the web service at that time i need advertising id but i got null.if you people had done previously please suggest me.thanks in advance.</p>
  </blockquote>