Logging switch realization
<p>This code:</p>

<pre><code>public class MyActivity extends Activity {

    private final boolean logging = getResources().getBoolean(R.bool.logging);

    @Override
    public void onCreate(Bundle savedInstanceState) {

        if(logging) Log.d("my_log", "some text here");

        // some onCreate code...
    }
}
</code></pre>

<p>generates NullPointerException.</p>

<p>But this one:</p>

<pre><code>public class MyActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {

        final boolean logging = getResources().getBoolean(R.bool.logging);
        if(logging) Log.d("my_log", "some text here");

        // some onCreate code...
    }
}
</code></pre>

<p>Does not.</p>

<p>The main idea to switch logging in entire application with a boolean resource.</p>

<p>I can successfully declare this variable for every function in class, but can it be done for entire class just once?</p>
