Brandex07 Brandex07 - 1 year ago 78
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 Source

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.