title: Explicit intents don't works on Android 8.1
body: <p>The code below works without any problem on pre-Oreo versions.</p>
  
  <p>Although I user <code>startForeground</code> method and making <code>explicit</code> intent to get Activity values, <code>onHandleIntent</code> method is never called.</p>
  
  <p>I cannot find any issue or solution about this issue.</p>
  
  <p>Is there any chance to overcome this issue?</p>
  
  <p>Note: I try on my phone which runs a custom ROM and I can not simulate on Android Emulator this circumstance.</p>
  
  <p><code>AndroidManifest.xml</code> file</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.myservice"
      android:versionCode="1"
      android:versionName="1.0"&gt;
  
      &lt;application ... &gt;
  
        &lt;service android:name="com.MyService"&gt;
          &lt;intent-filter&gt;
            &lt;action android:name="com.MyService"/&gt;
          &lt;/intent-filter&gt;
        &lt;/service&gt;
  
        &lt;uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" /&gt;
  
        &lt;service android:name="com.myservice.ActivityHelper$ActivityRecognitionService" /&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><code>MyService.java</code> file</p>
  
  <pre><code>public class MyService extends Service {
  
      ...
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          super.onStartCommand(intent, flags, startId);
  
          runServiceAtForeground();
  
          return START_STICKY;
      }
  
  
      private void runServiceAtForeground () {
          ...
  
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
              ...
              mNotificationManager.createNotificationChannel(channel);
          }
  
          Intent i = new Intent(getApplicationContext(), MyService.class);
          PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
          NotificationCompat.Builder notif = new NotificationCompat.Builder(this, channel_id);
          notif.setContentIntent(pi);
  
          // MAKING FOREGROUND SERVICE
          startForeground(notif_id, notif.build());
  
          // STARTING ACTIVITY RECOGNITION
          mActivityHelper.startObserving();
  
      }
  
      ...
  
  }
  </code></pre>
  
  <p><code>ActivityHelper.java</code> file</p>
  
  <pre><code>public class ActivityHelper {
  
      ...
  
      public void startObserving() {
          ActivityRecognitionClient arc = ActivityRecognition.getClient(context);
  
          Task&lt;Void&gt; task = arc.requestActivityUpdates(20000, getActivityDetectionPendingIntent());
  
          task.addOnSuccessListener(new OnSuccessListener&lt;Void&gt;() {...});
  
          task.addOnFailureListener(new OnFailureListener() {...});
      }
  
      private PendingIntent getActivityDetectionPendingIntent() {
              Intent i = new Intent(mContext, ActivityRecognitionService.class);
  
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
                  return PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
              } else {
                  return PendingIntent.getService(mContext, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
              }
      }
  
  
      public static class ActivityRecognitionService extends IntentService {
  
          public ActivityRecognitionService() {
              super("ActivityRecognitionService");
          }
  
          @Override
          public void onCreate() {
              super.onCreate();
          }
  
          @Override
          protected void onHandleIntent(Intent intent) {
  
              // THIS METHOD IS NEVER RUN ON OREO
  
              if (ActivityRecognitionResult.hasResult(intent)) {
                  ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
  
                  if (listener != null) {
                      Log.v(TAG, result.getMostProbableActivity().getType());
                  }
  
                  stopSelf();
              }
          }
  
      }
  
  }
  </code></pre>