title: How to call an Activity from service class
body: <pre><code>public class FinishService extends Service{
  
   private NotificationManager mNM;
   public static String ChangeDate;
   public static Context mContext;
   public static String today;
  
  
  
   private int NOTIFICATION = R.string.local_service_started;
   private int START_STICKY;
  
  
   public class LocalBinder extends Binder {
       FinishService getService() {
              return FinishService.this;
          }
      }
  
  
  
  
   @Override
  public void onCreate() {
       mContext=FinishService.this;
        mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
           showNotification();
  }
  
  
  
    @SuppressLint("Override")
          public int onStartCommand(Intent intent, int flags, int startId) {
              Log.i("LocalService", "Received start id " + startId + ": " + intent);
              Toast.makeText(this, "Service start", Toast.LENGTH_SHORT).show();
  
              // We want this service to continue running until it is explicitly
              // stopped, so return sticky.
              return START_STICKY;
          }
  
  
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      return mBinder;
  }
  
  //@Override
  public void onDestroy() {
  
              if(AstrobixStaticMethod.isInternetAvailable(FinishService.this)){
                   Date date = Calendar.getInstance().getTime(); 
                   DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
                   ChangeDate=formatter.format(date);
                  SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                  Calendar cal=Calendar.getInstance();
              try{
                  cal.setTime(sdf.parse(ChangeDate));
              }catch(Exception e){
  
              }
              cal.add(Calendar.DATE, 1);
              ChangeDate=sdf.format(cal.getTime());
              Toast.makeText(this, ""+ChangeDate, Toast.LENGTH_SHORT).show();
              Log.e("Next Date", ChangeDate);
              RahuActivity.nextAlaram();  
  
              }
              else{
                  Intent mIntent=new Intent(getApplicationContext(),Information.class);
                  mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  mContext.startActivity(mIntent);
  
  
              }
  
  
  }
  
  
  
  private final IBinder mBinder = new LocalBinder();
  
   @SuppressWarnings("deprecation")
      private void showNotification() {
          // This is the 'title' of the notification
          CharSequence title = "Rahukaal has finished.!!";
          // This is the icon to use on the notification
          int icon = R.drawable.ic_launcher;
          // This is the scrolling text of the notification
          //CharSequence text =RahuParserClasses.mList.get(0);
          CharSequence text ="Rahukaal Time Finished Now";
          // What time to show on the notification
          long time = System.currentTimeMillis();
          Notification notification = new Notification(icon, text, time);
          // The PendingIntent to launch our activity if the user selects this notification
          Intent notificationIntent = new Intent();
      //  PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, RahuTimeActivity.class), 0);
          PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
          // Set the info for the views that show in the notification panel.
          notification.setLatestEventInfo(this, title, text, contentIntent);
          // Clear the notification when it is pressed
          notification.flags |= Notification.FLAG_AUTO_CANCEL;
          //Vibrates fon on notification
          notification.vibrate=new long[] { 100, 250, 100, 500 };
          notification.defaults |= Notification.DEFAULT_SOUND;
          //Uri defaultRingtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
          // Send the notification to the system.
  
          mNM.notify(NOTIFICATION, notification);
  
  
          stopSelf();
  
      }
  </code></pre>
  
  <p>Can anyone help me.i make an application where i set the alarm from matching time.
  when time is matching service class is running but i have coded on destroy method 
  if internet is not available on phone.it will go to BroadcastReceiver class but it
  is gone and shows an error when application not open.</p>
  
  <p>Loacat error here:</p>
  
  <pre><code> java.lang.RuntimeException: Unable to stop service   com.astrobix.service.FinishService@40523370: android.content.ActivityNotFoundException:    Unable to find explicit activity class { com.astrobix.astrobixrahukaal/com.astrobix.service.Information}; have you declared this activity in your AndroidManifest.xml?
  </code></pre>