「Android/広告組込/google広告id」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==google広告id組み込みサンプル== MainActivity.java public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle saved...」) |
|||
行38: | 行38: | ||
} | } | ||
− | 端末のgoogle設定/ | + | 端末のgoogle設定/広告からid(GAID)を確認できる |
==参考== | ==参考== | ||
http://stackoverflow.com/questions/29363337/the-meta-data-tag-in-androidmanifest-xml-does-not-have-the-right-value | http://stackoverflow.com/questions/29363337/the-meta-data-tag-in-androidmanifest-xml-does-not-have-the-right-value |
2016年11月22日 (火) 17:48時点における版
google広告id組み込みサンプル
MainActivity.java
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new Thread(new Runnable() { @Override public void run() { AdvertisingIdClient.Info info = null; try { info = AdvertisingIdClient.getAdvertisingIdInfo(MainActivity.this.getApplicationContext()); } catch (IOException e) { e.printStackTrace(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } String advertiginID = info.getId(); boolean limitAdTrackingEnabled = info.isLimitAdTrackingEnabled(); Log.i("test", "広告id advertiginID=" + advertiginID); // 0d5a44d9-ad30-4717-b726-b756496xxxxx Log.i("test", "広告idを使用しないフラグ limitAdTrackingEnabled=" + limitAdTrackingEnabled); // false } }).start(); } }
version.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <integer name="google_play_services_version">6587000</integer> </resources>
build.gradle
dependencies { compile 'com.google.android.gms:play-services:6.5.87' }
端末のgoogle設定/広告からid(GAID)を確認できる