Professional Documents
Culture Documents
<service
android:name="com.example.servicetest.MySer
vice" />
@Override
public int onStartCommand(Intent
intent, int flags, int startId) {
// Ejecutar accin del servicio
return super.onStartCommand(intent,
flags, startId);
}
@Override
public void onDestroy() {
// Dar por terminado el servicio
super.onDestroy();
}
Intent i = new
Intent(MainActivity.this,
MyService.class);
startService(i);
Intent i = new
Intent(MainActivity.this,
MediaService.class);
stopService(i);
@Override
public IBinder onBind(Intent intent) {
// Un Activity se enlaza por primera vez al
return mBinder;
}
//Service
@Override
public void onRebind(Intent intent) {
// Un Activity se enlaza al Service despes de un
//llamado de onUnbind
}
@Override
public boolean onUnbind(Intent intent) {
// Todos los Activities se desenlazan del Service
return mAllowRebind;
}
if(mService !=null){
unbindService(mMyBoundServiceConnection);
mService = null;
}
}