I followed the instructions here, I'm compiling my app in the 14 API, I already setup a publisher ID, and everything is fine, except for: I can't test the ads on my app because I can't find that "adRequest" filtered to find my device ID, and because testing on an emulator does not work as well. And, to make things worse: I don't know, exactly, how to call the ad activity on my app activity. Here we go:
I've created a class called "Money":
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
/**
* Created by EricsonWillians on 07/03/14.
*/
public class Money extends Activity {
private AdView adView;
private static final String AD_UNIT_ID = "My Publisher ID 9348923432342";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.addView(adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
.build(); // Can't find the bloody "hashed device ID" even filtering the whole logcat (I'm using IntelliJ IDEA).
// Start loading the ad in the background.
adView.loadAd(adRequest);
}
@Override
public void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}
}
@Override
public void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}
/** Called before the activity is destroyed. */
@Override
public void onDestroy() {
// Destroy the AdView.
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
And, to make things worse again, I've changed the code to try to use the emulator:
AdRequest adRequest = new AdRequest.Builder().build();
adRequest.addTestDevices(AdRequest.TEST_EMULATOR); // Does not work.
And I get from the IDE that the "addTestDevices" method and the AdRequest.TEST_EMULATOR cannot be resolved.
How can I get my device ID on that logcat, and how can I call this ad activity in my app activity?