title: My JobService not working in Android 10 but Working fine in Android 9 and lower
body: <p>I'm creating an Android app that sends a notification when user copy to clipboard from system while the app is running in the background. For this, I'm using JobService. But my JobService not working in Android 10 and upper but it works fine in Android 9 and lower.</p>
  <p>Here is my ClipboardJobService java class:</p>
  <pre><code>public class ClipboardJobService extends JobService {
  private static final String TAG = &quot;ClipboardJobService&quot;;
  private static final String CHANNEL_ID = &quot;clipboard_copy_event&quot;;
  private static final String CHANNEL_NAME = &quot;Clipboard Copy Event&quot;;
  private static final int NOTIFICATION_ID = 2342;
  private NotificationManager notificationManager;
  private ClipboardManager clipboardManager;
  
  @Override
  public boolean onStartJob(JobParameters params) {
      notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  
      clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      clipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
  
      Log.e(TAG, &quot;onStartJob: Service Started&quot; );
      return false;
  }
  
  @Override
  public boolean onStopJob(JobParameters params) {
      Log.e(TAG, &quot;onStopJob: Service finished&quot; );
      return true;
  }
  
  private void createNotificationChannel() {
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
          NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
          channel.setName(&quot;Jobless Joker&quot;);
          channel.setDescription(&quot;Go To ClipboardServiceExample App&quot;);
  
          notificationManager.createNotificationChannel(channel);
      }
  }
  
  private NotificationCompat.Builder getNotificationBuilder() {
      NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, CHANNEL_ID);
      notificationBuilder.setContentTitle(&quot;InstaLoader&quot;);
      notificationBuilder.setContentText(&quot;This is Description&quot;);
      notificationBuilder.setAutoCancel(true);
      notificationBuilder.setSmallIcon(R.drawable.ic_launcher_background);
  
      return notificationBuilder;
  }
  
  private ClipboardManager.OnPrimaryClipChangedListener mOnPrimaryClipChangedListener =
          new ClipboardManager.OnPrimaryClipChangedListener() {
              @Override
              public void onPrimaryClipChanged() {
                  //Create notification channel
                  createNotificationChannel();
                  //Create Notification builder
                  NotificationCompat.Builder notifyBuilder = getNotificationBuilder();
                  if (clipboardManager != null)
                      notifyBuilder.setContentText(clipboardManager.getPrimaryClip().getItemAt(0).getText());
                  //Notify to the notification manager
                  notificationManager.notify(NOTIFICATION_ID, notifyBuilder.build());
                  Log.e(TAG, &quot;onPrimaryClipChanged: &quot;);
              }
          };}
  </code></pre>
  <p>And here is my MainActivity class:</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  private static final int JOB_ID = 234123;
  private JobScheduler jobScheduler;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      jobScheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
  
      ComponentName serviceName = new ComponentName(getPackageName(),
              ClipboardJobService.class.getName());
  
      JobInfo.Builder jobBuilder = new JobInfo.Builder(JOB_ID, serviceName)
              .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
  
      JobInfo myJobInfo = jobBuilder.build();
      jobScheduler.schedule(myJobInfo);
  }}
  </code></pre>