title: How to reconnect the Network Connection in Android Application?
body: <p>Hai t try to detect the net connection is available for frequently.So i tried by  BroadcastReceiverfunction.But Its not Working.any Body kindly Help me
  Thanks in advance!
  <strong>I want to Check 5 sec ones</strong></p>
  
  <pre><code>Intent Broadcast = new Intent(this,ReceiverName.class);
  startActivity(Broadcast);
  </code></pre>
  
  <p>Above coding is to Cal the Class ReceiverName</p>
  
  <pre><code>package com.android.cdtech;
  
  import android.app.Activity;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.database.Cursor;
  import android.net.ConnectivityManager;
   import android.view.View;
  
   class ReceiverName extends Activity {
   BroadcastReceiver r = new BroadcastReceiver(){
  
      @Override
      public void onReceive(Context context, Intent intent) {
           ConnectivityManager cm = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
              if (cm == null)
                  return;
              if (cm.getActiveNetworkInfo() != null &amp;&amp; cm.getActiveNetworkInfo().isConnected()) {
                  saveData();
              } else {
                  // Do nothing or notify user somehow
              }
  
      }
     // code to handle broadcase
  
      private void saveData() {
          final saveData dh=new saveData(null);
          webService calService=new  webService();
           dh.open();
           Cursor c = dh.pay();
           String text = "";
           do{
            text = text+ " "+"\n"+c.getString(4);
            System.out.println(c.getCount());
           // Toast.makeText(this,"Name:" +c.getString(1)+c.getString(2)+c.getString(3)+c.getString(4)+"",Toast.LENGTH_LONG).show();
  
            calService.paymentReceipt("PaymentReceipt",c.getString(1),c.getString(2),c.getString(3),c.getString(4),"gf","0");
           }
           while (c.moveToNext()); 
           dh.close();
  
      }
   };
  }
  </code></pre>