title: Create a Scheduled service in android
body: <p>I need to create a schedule service in android with java. I have tried some codes , but all time after build the application it doesn't run. My logic is simple , I want to make a service to check the existence of a file in the bluetooth folder path, If this file is there , so this service will run another application , I need this with a schedule which run every 2 minutes.</p>
  
  <p>Until now that's great, but now I have an error <code>The method startActivity(Intent) is undefined for the type MyTimerTask</code>. I have tried this code...</p>
  
  <pre><code>public class MyTimerTask extends TimerTask {
      java.io.File file = new java.io.File("/mnt/sdcard/Bluetooth/1.txt");
  
      public void run(){ 
          if (file.exists()) {
              Intent intent = new Intent(Intent.ACTION_MAIN);
              intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity"));
              startActivity(intent);
          }
      } 
  }
  </code></pre>
  
  <p>Could someone please help me with this.</p>