title: Broadcast receiver is not registering (working) in Android Pie
body: <p>Here my code is working till Marshmallow devices but in my Pie devices it is not working.</p>
  
  <p>I read a Google documentation and found remove the receiver tag from manifest and add in activity but I can't understand how to add.</p>
  
  <p>Main problem is when I adding a value in offline mode its stores a value in SQLite but when come in back online mode it does not send SQLite data to server above nogout devices.</p>
  
  <p>Here is my activity:</p>
  
  <pre><code>  broadcastReceiver = new BroadcastReceiver() {
              @Override
              public void onReceive(Context context, Intent intent) {
  
                  readFromLocalStorage();
              }
          };
  
       buttonAdd.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  SubmitMethode();
  //                addPremises();
                  relativeLayoutAdd.setVisibility(View.GONE);
                  linearLayoutRecycler.setVisibility(View.VISIBLE);
                  imageButtonPlus.setVisibility(View.VISIBLE);
              }
          });
      }
  
  
      private void SubmitMethode() {
          preName = Objects.requireNonNull(editTextPremises.getText()).toString();
          prewifiName = Objects.requireNonNull(editTextwifiName.getText()).toString();
          prewifiUrl = Objects.requireNonNull(editTextwifiUrl.getText()).toString();
          preserverUrl = Objects.requireNonNull(editTextserverUrl.getText()).toString();
          preImage = getStringImage(bitmap);
          Log.d("responseT",preName + "==" + prewifiName + "==" + prewifiUrl);
  
          saveToAppServer(preName, prewifiName, prewifiUrl, preserverUrl, preImage);
          editTextPremises.setText("");
          editTextwifiName.setText("");
          editTextwifiUrl.setText("");
          editTextserverUrl.setText("");
          textViewSelect.setText("Select Image");
      }
  
      private void readFromLocalStorage(){
  
          sqPremisesList.clear();
          DBHelper dbHelper = new DBHelper(this);
          SQLiteDatabase sqLiteDatabase = dbHelper.getReadableDatabase();
  
          Cursor cursor = dbHelper.readFromLocalDatabase(sqLiteDatabase);
          while (cursor.moveToNext()){
              String premisesName = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_NAME));
              String premisesWifiName = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_WIFI_NAME));
              String premisesWifiUrl = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_WIFIURL));
              String premisesServerUrl = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_SERVERURL));
              String premisesImagePath = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_IMAGEPATH));
              int sync_status = cursor.getInt(cursor.getColumnIndex(DBContact.SYNC_STATUS));
  
  
              sqPremisesList.add(new SqPremises(premisesName, premisesWifiName,
                      premisesWifiUrl, premisesServerUrl, premisesImagePath, sync_status));
          }
  //
          sqPremisesAdapter.notifyDataSetChanged();
          cursor.close();
          /*TODO: // this is new line code*/
          dbHelper.close();
      }
  
      private void saveToAppServer(final String pName, final String pWifiName, final String pWifiUrl,
                                   final String pServerUrl, final String pImage){
  
          if (checkNetworkConnection()){
  
              progressDialog.setTitle("Adding....");
              progressDialog.setMessage("please wait while we are waiting your premises");
              progressDialog.show();
  
              String Url = Constant.BASE_URL + "addpremises/";
  
              HashMap&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("user", userID);
              params.put("name", preName);
              params.put("wifi_name", prewifiName);
              params.put("online_url", prewifiUrl);
              params.put("offline_url", preserverUrl);
              params.put("image", preImage);
              Log.d("responseV", String.valueOf(params));
  
  
              JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Url, new JSONObject(params),
                      new Response.Listener&lt;JSONObject&gt;() {
                          @Override
                          public void onResponse(JSONObject response) {
                              Log.d("responseJ", String.valueOf(response));
                              progressDialog.dismiss();
                              try {
                                  String statusObject = response.getString("status");
                                  String msgObject = response.getString("msg");
  
                                  if (statusObject.equals("200")) {
  
                                      Toast.makeText(PremisesManagementActivity.this, msgObject, Toast.LENGTH_SHORT).show();
  
                                      saveToLocalStorage(pName, pWifiName, pWifiUrl, pServerUrl, pImage, DBContact.SYNC_STATUS_OK);
  
                                      linearLayoutAsk.setVisibility(View.GONE);
                                      relativeLayoutAdd.setVisibility(View.GONE);
                                      imageButtonPlus.setVisibility(View.VISIBLE);
                                      linearLayoutRecycler.setVisibility(View.VISIBLE);
  
                               /*   String value = "false";
                                  SharedPreferences.Editor editor = sharedPreferences.edit();
                                  editor.putString("value",value);
                                  editor.commit();*/
  
                                  }else {
                                      Toast.makeText(PremisesManagementActivity.this, msgObject, Toast.LENGTH_SHORT).show();
  //                                linearLayoutAsk.setVisibility(View.VISIBLE);
  //                                imageButtonPlus.setVisibility(View.VISIBLE);
  //                                linearLayoutRecycler.setVisibility(View.GONE);
  //                                relativeLayoutAdd.setVisibility(View.GONE);
                                      saveToLocalStorage(pName, pWifiName, pWifiUrl, pServerUrl, pImage, DBContact.SYNC_STATUS_FAILED);
  
                                  }
                              }catch (JSONException e){
                                  e.printStackTrace();
                              }
  
                          }
                      }, new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
  //                    error.printStackTrace();
                      saveToLocalStorage(pName, pWifiName, pWifiUrl, pServerUrl, pImage, DBContact.SYNC_STATUS_FAILED);
  
                  }
              });
  
          requestQueue.add(jsonObjectRequest);
  
  //            MySingleton.getInstance(PremisesManagementActivity.this).addToRequestQue(jsonObjectRequest);
          }else {
              saveToLocalStorage(pName, pWifiName, pWifiUrl,
                      pServerUrl, pImage, DBContact.SYNC_STATUS_FAILED);
          }
  
  
      }
   private void saveToLocalStorage (String pName, String pWifiName, String pWifiUrl,
                                       String pServerUrl,String pImage, int sync){
  
          DBHelper dbHelper = new DBHelper(this);
          SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
          dbHelper.saveToLocalDatabase(pName, pWifiName, pWifiUrl, pServerUrl, pImage,  sync , sqLiteDatabase);
          readFromLocalStorage();
          dbHelper.close();
  
      }
  //
      @RequiresApi(api = Build.VERSION_CODES.O)
      @Override
      protected void onStart() {
          super.onStart();
          registerReceiver(broadcastReceiver, new IntentFilter(DBContact.UI_UPDATE_BROADCAST));
  
  //            IntentFilter filter = new IntentFilter(DBContact.UI_UPDATE_BROADCAST);
  //            registerReceiver(broadcastReceiver, filter, Manifest.permission.CHANGE_NETWORK_STATE, null);
  //            sendBroadcast();
  
  
      }
  
  
      @Override
      protected void onPause() {
          super.onPause();
          unregisterReceiver(broadcastReceiver);
      }
  </code></pre>
  
  <p>And it is receiver which is add on manifest file:</p>
  
  <pre><code>  &lt;receiver android:name=".utils.NetworkMonitor"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.net.conn.CONNECTIVITY_CHANGE" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  </code></pre>
  
  <p>And here I am adding my Network monitor file:</p>
  
  <pre><code>if (checkNetworkConnection(context)){
              final DBHelper dbHelper = new DBHelper(context);
              final SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
  
              Cursor cursor = dbHelper.readFromLocalDatabase(sqLiteDatabase);
  
              while (cursor.moveToNext()){
                  int sync_status = cursor.getInt(cursor.getColumnIndex(DBContact.SYNC_STATUS));
                  if (sync_status == DBContact.SYNC_STATUS_FAILED){
  
                      final String premisName = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_NAME));
                      final String premisWifiName = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_WIFI_NAME));
                      final String premisWifiUrl = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_WIFIURL));
                      final String premisServerUrl = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_SERVERURL));
                      final String premisesImagePath = cursor.getString(cursor.getColumnIndex(DBContact.PREMISES_IMAGEPATH));
  
  
  
                      String Url = Constant.BASE_URL + "addpremises/";
  
                      HashMap&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
                      params.put("user", userID );
                      params.put("name", premisName);
                      params.put("wifi_name", premisWifiName);
                      params.put("online_url", premisWifiUrl);
                      params.put("offline_url", premisServerUrl);
                      params.put("image",premisesImagePath);
                      Log.d("responseV", String.valueOf(params));
  
                      JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Url, new JSONObject(params),
                              new Response.Listener&lt;JSONObject&gt;() {
                                  @Override
                                  public void onResponse(JSONObject response) {
                                      Log.d("responseJ", String.valueOf(response));
  
                                      try {
                                          String statusObject = response.getString("status");
                                          String msgObject = response.getString("msg");
  
                                          if (statusObject.equals("200")) {
                                              dbHelper.updateLocalDatabase(premisName, premisWifiName, premisWifiUrl,
                                                      premisServerUrl, premisesImagePath, DBContact.SYNC_STATUS_OK, sqLiteDatabase);
  
                                              context.sendBroadcast(new Intent(DBContact.UI_UPDATE_BROADCAST));
                                          }
                                      }catch (JSONException e) {
                                          e.printStackTrace();
                                      }
                                  }
                              }, new Response.ErrorListener() {
                          @Override
                          public void onErrorResponse(VolleyError error) {
                              Log.d("responseE", String.valueOf(error.getMessage()));
                          }
                      });
                      requestQueue.add(jsonObjectRequest);
                  }
              }
  
  
          }
  
      }
  
      public boolean checkNetworkConnection(Context context){
  
          ConnectivityManager connectivityManager =
                  (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
          return (networkInfo != null &amp;&amp; networkInfo.isConnected());
      }
  </code></pre>
  
  <p>How can I solve this problem? I am a beginner to broadcast receiver.</p>