title: how to cal the activity method from the service
body: <p>How  to call a method at the time From the service to activity. I want to cal  only particular method From the service .am using timer function and handler.</p>
  
  <p>In my Activity the method name is savedata(), i want to cal this function</p>
  
  <p>service</p>
  
  <pre><code>public class MyService extends Service 
  {
      @Override
      public IBinder onBind(Intent intent) 
      {
          return null;
      }
  
      @Override
      public void onCreate() 
      {
          Log.d(TAG, "onCreate");
      }
  
      @Override
      public void onDestroy() 
      {
          Log.d(TAG, "onDestroy");
      }
  
      public void onStart(Intent intent, int startid) 
      {
          Timer mTimer = new Timer(user);
          mTimer.scheduleAtFixedRate(new mainTask(), 5000,60000);//1 hour=3600 s
  
      }
  
      private class mainTask extends TimerTask 
      { 
          public void run() 
          {
              toastHandler.sendEmptyMessage(0);
          }
      }  
  
  
      private final Handler toastHandler = new Handler() 
      {
          public void handleMessage(Message msg) 
          {
                  Intent myIntent = new Intent(getBaseContext(),StorageHelper.class);
                  myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  startActivity(myIntent);//here i start the activity but i need to acces the particular method only.
  
          }
      };    
  
   }
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p><strong>Activity</strong></p>
  
  <pre><code>public class StorageHelper extends Activity
  {
      final DBAdapter1 database=new DBAdapter1(this);
  
  MessageCount objmsgCount=new MessageCount();
  String msgCount;
  int count;
  String []tokens=null;
  String notify=null;
  int userid=71; 
  
  
   public  String savedata()
      {
          msgCount=objmsgCount.getMessageCount();
          {
              try {
                  database.open();
              } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              }
                      long id=database.insert(71,4,"yes"); 
                      database.close();
  
          return "success";
      }
  }
  </code></pre>