Android Open Source - vitdroid-android My Service4 From Project Back to project page vitdroid-android .
License The source code is released under:
Apache License
If you think the Android project vitdroid-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.googlecode.android.widgets.DateSlider;
/ / w w w . j a v a 2 s . c o m
import android.app.ActivityManager;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.text.format.DateFormat;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import javax.security.auth.callback.Callback;
public class MyService4 extends Service
{
int counter=0;
int serv=0;
int notificationID=1;
static final int UPDATE_INTERVAL=1000;
int serv_start;
private Timer timer=new Timer();
@Override
public IBinder onBind(Intent arg0)
{
return null;
}
@Override
public int onStartCommand(Intent intent,int flags,int startId)
{
Log.d("rahul" ,"thisi has started" );
dosomething();
return START_STICKY;
}
private void dosomething()
{
//System.out.println(minute1);
timer.scheduleAtFixedRate(new TimerTask(){
public void run()
{
Log.d("my service main" ,String.valueOf(++counter));
Calendar no=Calendar.getInstance();
if (no.getTime().getHours()==0 && no.getTime().getMinutes()==0 && no.getTime().getSeconds()==0)
serv=0;
//break;
start();
//Toast.makeText(this, "service started", Toast.LENGTH_SHORT).show();
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (MyService.class.getName().equals(service.service.getClassName())) {
Log.d("rahul" ,"service running" );
}
}
}
}, 0, UPDATE_INTERVAL);
}
void start()
{
Log.d("the value of serv is" ,String.valueOf(serv));
Calendar now=Calendar.getInstance();
if (now.getTime().getHours()==7 && now.getTime().getMinutes()==0 && now.getTime().getSeconds()==0)
{
startService(new Intent(getBaseContext(),MyService5.class));
serv=1;
}
if (serv==0 && now.getTime().getHours()>=7)
{
Log.d("inside serv" ,"yes i am" );
startService(new Intent(getBaseContext(),MyService5.class));
serv=1;
}
}
@Override
public void onDestroy()
{
System.out.println("destroyed b oss" );
super.onDestroy();
if (timer!=null)
{
timer.cancel();
}
Toast.makeText(this , "service destroyed" , Toast.LENGTH_SHORT).show();
}
}
Java Source Code List com.googlecode.android.widgets.DateSlider.AlternativeDateSlider.java com.googlecode.android.widgets.DateSlider.Attendance.java com.googlecode.android.widgets.DateSlider.Attendanceboth.java com.googlecode.android.widgets.DateSlider.BackGroundDialogs.java com.googlecode.android.widgets.DateSlider.Base64.java com.googlecode.android.widgets.DateSlider.CustomDateSlider.java com.googlecode.android.widgets.DateSlider.DBAdapter2.java com.googlecode.android.widgets.DateSlider.DBAdapter3.java com.googlecode.android.widgets.DateSlider.DBAdapter5.java com.googlecode.android.widgets.DateSlider.DBAdapter6.java com.googlecode.android.widgets.DateSlider.DBAdapter.java com.googlecode.android.widgets.DateSlider.DBAdaptergrades.java com.googlecode.android.widgets.DateSlider.DBAdapterlinks.java com.googlecode.android.widgets.DateSlider.DateSlider.java com.googlecode.android.widgets.DateSlider.DateTimeSlider.java com.googlecode.android.widgets.DateSlider.DefaultDateSlider.java com.googlecode.android.widgets.DateSlider.Demo.java com.googlecode.android.widgets.DateSlider.FacultyCabin.java com.googlecode.android.widgets.DateSlider.Faculty.java com.googlecode.android.widgets.DateSlider.GAttendance.java com.googlecode.android.widgets.DateSlider.GDBAdapter5.java com.googlecode.android.widgets.DateSlider.GDBAdapter6.java com.googlecode.android.widgets.DateSlider.GDBAdapter.java com.googlecode.android.widgets.DateSlider.GFaculty.java com.googlecode.android.widgets.DateSlider.GMarks.java com.googlecode.android.widgets.DateSlider.GStudent.java com.googlecode.android.widgets.DateSlider.GuestLogin.java com.googlecode.android.widgets.DateSlider.GuestMainscreen.java com.googlecode.android.widgets.DateSlider.Login.java com.googlecode.android.widgets.DateSlider.Mainscreen.java com.googlecode.android.widgets.DateSlider.MarkAttendance.java com.googlecode.android.widgets.DateSlider.Marks.java com.googlecode.android.widgets.DateSlider.MinimalDemo.java com.googlecode.android.widgets.DateSlider.MonthYearDateSlider.java com.googlecode.android.widgets.DateSlider.MyService2.java com.googlecode.android.widgets.DateSlider.MyService4.java com.googlecode.android.widgets.DateSlider.MyService5.java com.googlecode.android.widgets.DateSlider.MyService.java com.googlecode.android.widgets.DateSlider.ObservableScrollView2.java com.googlecode.android.widgets.DateSlider.ObservableScrollView.java com.googlecode.android.widgets.DateSlider.QuizRem3.java com.googlecode.android.widgets.DateSlider.QuizRem4.java com.googlecode.android.widgets.DateSlider.Quiz.java com.googlecode.android.widgets.DateSlider.Refresh.java com.googlecode.android.widgets.DateSlider.SMainScreen.java com.googlecode.android.widgets.DateSlider.ScrollLayout.java com.googlecode.android.widgets.DateSlider.ScrollViewListener2.java com.googlecode.android.widgets.DateSlider.ScrollViewListener.java com.googlecode.android.widgets.DateSlider.ServiceManager.java com.googlecode.android.widgets.DateSlider.Settings.java com.googlecode.android.widgets.DateSlider.SimpleGestureFilter.java com.googlecode.android.widgets.DateSlider.SliderContainer.java com.googlecode.android.widgets.DateSlider.Student.java com.googlecode.android.widgets.DateSlider.TimeObject.java com.googlecode.android.widgets.DateSlider.TimeSlider.java com.googlecode.android.widgets.DateSlider.ViewflipActivity.java com.googlecode.android.widgets.DateSlider.labeler.DayDateLabeler.java com.googlecode.android.widgets.DateSlider.labeler.DayLabeler.java com.googlecode.android.widgets.DateSlider.labeler.HourLabeler.java com.googlecode.android.widgets.DateSlider.labeler.Labeler.java com.googlecode.android.widgets.DateSlider.labeler.MinuteLabeler.java com.googlecode.android.widgets.DateSlider.labeler.MonthLabeler.java com.googlecode.android.widgets.DateSlider.labeler.MonthYearLabeler.java com.googlecode.android.widgets.DateSlider.labeler.TimeLabeler.java com.googlecode.android.widgets.DateSlider.labeler.Util.java com.googlecode.android.widgets.DateSlider.labeler.WeekLabeler.java com.googlecode.android.widgets.DateSlider.labeler.YearLabeler.java com.googlecode.android.widgets.DateSlider.timeview.DayTimeLayoutView.java com.googlecode.android.widgets.DateSlider.timeview.TimeLayoutView.java com.googlecode.android.widgets.DateSlider.timeview.TimeTextView.java com.googlecode.android.widgets.DateSlider.timeview.TimeView.java com.googlecode.android.widgets.DateSlider.global.java com.googlecode.android.widgets.DateSlider.grades.java com.googlecode.android.widgets.DateSlider.notif2.java com.googlecode.android.widgets.DateSlider.notif.java com.googlecode.android.widgets.DateSlider.pbl.java com.googlecode.android.widgets.DateSlider.sample.java in.ac.vit.vitdroid.DBAdaptergrades.java in.ac.vit.vitdroid.DBAdapterlinks.java