How to use boolean value returned by a method
<p>I just want to know how to use a boolean value returned from a method.This is the method which is returning the value:</p>

<pre><code> public  boolean hasConnection() {
            ConnectivityManager cm = (ConnectivityManager) MCQ.this.getBaseContext().getSystemService(
                Context.CONNECTIVITY_SERVICE);

            NetworkInfo wifiNetwork = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            if (wifiNetwork != null &amp;&amp; wifiNetwork.isConnectedOrConnecting()) {
              return true;
            }

            NetworkInfo mobileNetwork = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
            if (mobileNetwork != null &amp;&amp; mobileNetwork.isConnectedOrConnecting()) {
              return true;
            }

            NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
            if (activeNetwork != null &amp;&amp; activeNetwork.isConnectedOrConnecting()) {
              return true;
            }

            return false;
          }
</code></pre>

<p>This is the method where i want to use this value:</p>

<pre><code>public void setScrollViewLayoutMarginBottom()
     {
         Resources resources = this.getResources();
          DisplayMetrics metrics = resources.getDisplayMetrics();

          Boolean b = hasConnection();

         if(b == true)
         {
             px = 90 * (metrics.densityDpi/160f); 
         }
         else
             px = 60 * (metrics.densityDpi/160f); 


         layoutParams.bottomMargin = (int) px;
            layoutParams.setMargins(0, 0, 0, (int) px);
            sv.setLayoutParams(layoutParams);
     }
</code></pre>

<p>Please help me.Thanks in advance.</p>
