private class GoogleAppIdTask extends AsyncTask<Void, Void, String> {
protected String doInBackground(final Void... params) {
String adId = null;
try {
adId = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()).getId();
Log.d("Debugadid","adid : " + adId);
} catch (IllegalStateException ex) {
ex.printStackTrace();
Log.e("Erroradid","IllegalStateException");
} catch (GooglePlayServicesRepairableException ex) {
ex.printStackTrace();
Log.e("Erroradid","GooglePlayServicesRepairableException");
} catch (IOException ex) {
ex.printStackTrace();
Log.e("Erroradid","IOException");
} catch (GooglePlayServicesNotAvailableException ex) {
ex.printStackTrace();
Log.e("Erroradid","GooglePlayServicesNotAvailableException");
}
return adId;
}
protected void onPostExecute(String adId) {
//TODO::Ad ID를 이용한 작업 수행
deviceid=adId;
}
}
GoogleAppIdTask에 노란불 나와서 static으로 해야되고 안그러면 leak할수 있다고 나오는데 static으로하면 밑에또 빨간줄나와서 ㅠㅠ
new GoogleAppIdTask().execute();
onCreate에서 위 코드로 실행했습니다.. 어떻게 하면 좋을까요 앱키면 맨 처음에만 강제 종료되고 두번째 킬때부터는 정상적으로 작동하는데 도와주세요!!