Monday, June 20, 2011

Android Services Example

Create Following Class for Services.

import android.app.Service;
import android.content.Intent;

import android.os.IBinder;
import android.util.Log;


public class MyServices extends Service{
private static final String TAG = MyServices.class.getSimpleName();
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG,"MyServices Created");
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Log.d(TAG,"MyServices Started");
}
@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG,"MyServices Destroyd");
}

}

Register Services in AndroidManifest.xml file.

service android:name=".MyServices"


Call(Start) Services in Activity.

startService(new Intent(this,MyServices.class));

No comments:

Post a Comment