, i've implemented an application running a backgroundservice . A couple weeks ago , things were working but now it doesn't running and i got the error : java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ComponentName android.content.Intent.getComponent()' on a null object reference . Here's what i have implemented :
//Service code :
@RequiresApi(api = Build.VERSION_CODES.R)
public class TimeService extends Service {
    private final static String TAG = TimeService.class.getName();
  
   
    @Override
    public void onCreate() {
        super.onCreate();
      
       //Code to run
}
               
      @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        
        //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        //            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        //                startForegroundService(new Intent(this, TimeService.class));
        //                Log.d("TAG","service has started ");
        //
        //            }
        //        }
             //   Log.d("TAG","service has started ");
                Intent startServiceIntent = null;
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
                    startServiceIntent = new Intent( this, TimeService.class);
                }
                startService(startServiceIntent);
            }
