Get Android Advertising ID (AAID)When you try to Add a Facebook advertising network ad in your Android Application you need to add your test device information to test add implementation you need to add your Android Advertisement ID (AAID). Here is a simple code to get your AAID.

How to Get AAID for Facebook Ads?

You can get Your Android Application ID (AAID) programmatically using the below code. You can call the below method in your onCreate method.



public void getAAID()
    AsyncTask.execute(new Runnable() {
        public void run() {
            try {
                AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(MyActivity.this);
                String myId = adInfo != null ? adInfo.getId() : null;

            } catch (Exception e) {
                 Log.e("error", e);

Note you need to import all required classes.