Brandex07 Brandex07 - 4 months ago 18
Android Question

Trying to use Log.d function from static context in Android

Log.d seems to not be displaying anything in my terminal. Is this related to using a static method?

public static void setPosition(int pos){
DetailActivity.pos = pos;
DetailActivity.counter++;

Log.d("counter", "" + counter);

if(DetailActivity.counter == 1){
//ad
if (DetailActivity.mInterstitialAd.isLoaded()) {
DetailActivity.mInterstitialAd.show();
counter = 0;
}
}
}

Answer

Log is going to print to LogCat. In Android Studio, go to the Android Monitor tab to see this output.

You may add filters for your tag or message in the search box, for example entering "counter" should show your message.

Comments