title: Broadcast Receiver not receiving intent (RemoteViews / PendingIntent)
body: <p>I am working on a custom notification which contains two buttons. I am using RemoteViews and used PendingIntent so that it will be received in the broadcast receiver. It is working fine in Huawei device but not working in Oppo &amp; Infinix devices.</p>
  <p>I am registering broadcast receiver like this in <strong>manifest</strong>:</p>
  <pre><code>&lt;receiver android:name=&quot;com.appedia.flashlight.torch.Notification_Receiver&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;Notification_Flashlight&quot;&gt;&lt;/action&gt;
                  &lt;action android:name=&quot;Notification_SOS&quot;&gt;&lt;/action&gt;
                  &lt;action android:name=&quot;Notification_Delete&quot;&gt;&lt;/action&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  </code></pre>
  <p>Using these methods in the <strong>Main Activity</strong> for notification:</p>
  <pre><code>public void Notification()
          {
              builder = new NotificationCompat.Builder(this);
              builder.setAutoCancel(true)
                      .setCustomContentView(remoteViews)
                      .setDeleteIntent(delete_pending_intent)
                      .setContentIntent(pendingIntent);
      
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M)
              {
                  builder.setSmallIcon(R.drawable.flashlight);
              }
              else
              {
                  builder.setSmallIcon(R.mipmap.ic_launcher);
              }
      
      
              if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.O)
              {
                  int importance = NotificationManager.IMPORTANCE_HIGH;
                  NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, importance);
                  assert notificationManager != null;
                  builder.setChannelId(NOTIFICATION_CHANNEL_ID);
                  notificationManager.createNotificationChannel(notificationChannel);
              }
      
              assert notificationManager != null;
          }
      
          public void NotificationItemsClickIntent()
          {
              Intent notification_intent = new Intent(getApplicationContext(),MainActivity.class);
              pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notification_intent, 0);
      
              Intent notification_deleted_intent = new Intent(&quot;Notification_Delete&quot;);
              notification_deleted_intent.putExtra(&quot;notification_delete&quot;, &quot;notification_delete&quot;);
              delete_pending_intent = PendingIntent.getBroadcast(getApplicationContext(), 0, notification_deleted_intent, PendingIntent.FLAG_UPDATE_CURRENT);
      
      
              /* Pending Intent for Notification Flashlight Button */
              //Intent with flashlight button for triggering Broadcast Receiver when clicked from notification bar
              Intent notification_flashlight_intent = new Intent(&quot;Notification_Flashlight&quot;);
              notification_flashlight_intent.putExtra(&quot;notification_flashlight&quot;, &quot;Flashlight&quot;);
      
              //start flashlight when notification bar button is clicked
              PendingIntent notification_flashlight_button = PendingIntent.getBroadcast(this,0,notification_flashlight_intent,PendingIntent.FLAG_UPDATE_CURRENT);
              remoteViews.setOnClickPendingIntent(R.id.notification_flashlight_button, notification_flashlight_button);
      
              /* Pending Intent for Notification SOS Button */
              //Intent with sos button for triggering Broadcast Receiver when clicked from notification bar
              Intent notification_sos_intent = new Intent(&quot;Notification_SOS&quot;);
              notification_sos_intent.putExtra(&quot;notification_sos&quot;, &quot;SOS&quot;);
      
              //start flashlight when notification bar button is clicked
              PendingIntent notification_sos_button = PendingIntent.getBroadcast(this,0,notification_sos_intent,PendingIntent.FLAG_UPDATE_CURRENT);
              remoteViews.setOnClickPendingIntent(R.id.notification_sos_button, notification_sos_button);
          }
      
          //broadcast receiver for getting battery percentage
          private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
              @Override
              public void onReceive(Context ctx, Intent intent) {
      
                  boolean isPlugged;
      
                  int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
                  remoteViews.setTextViewText(R.id.notification_battery_percent,String.valueOf(level) + &quot;%&quot;);
      
                  int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
                  isPlugged = plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB;
      
                  if(isPlugged)
                  {
                      remoteViews.setTextViewText(R.id.notification_battery_text, &quot;Charging&quot;);
                  }
                  else
                  {
                      remoteViews.setTextViewText(R.id.notification_battery_text, &quot;Discharging&quot;);
                  }
      
                  NotificationItemsClickIntent();
                  Notification();
                  notificationManager.notify(0, builder.build());
  
                  unregisterReceiver(mBatInfoReceiver);
                  }
              };
  </code></pre>
  <p>Starting notification service and registering broadcast receiver for battery information like this in onCreate of MainActivity:</p>
  <pre><code>//Starting Notification Service
          notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
          remoteViews = new RemoteViews(getPackageName(),R.layout.notification_bar);
  
      //for getting battery percentage (shows notification)
          this.registerReceiver(this.mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
      
                
  </code></pre>
  <p><strong>Notification Broadcast Receiver:</strong></p>
  <pre><code>public class Notification_Receiver extends BroadcastReceiver {
  
  String notification_flashlight, notification_sos, notification_delete;
  
  @Override
  public void onReceive(Context context, Intent intent) {
  
      notification_flashlight = intent.getExtras().getString(&quot;notification_flashlight&quot;);
      notification_sos = intent.getExtras().getString(&quot;notification_sos&quot;);
      notification_delete = intent.getExtras().getString(&quot;notification_delete&quot;);
  
      if (notification_flashlight != null) {
  
          Toast.makeText(context, &quot;Flashlight&quot;, Toast.LENGTH_SHORT).show();
      }
  
      else if (notification_sos != null) {
  
          Toast.makeText(context, &quot;SOS&quot;, Toast.LENGTH_SHORT).show();
      }
  
      else if (notification_delete != null) {
  
          Toast.makeText(context, &quot;Delete&quot;, Toast.LENGTH_SHORT).show();
         
      }
  }
  </code></pre>
  <p>Can anyone please help me? I don't know what am i doing wrong</p>