I am creating an application that intercepts an sms via BroadcastReceiver
, but from that I want to receive a sms via broadcast
open service
. probably this is done via Intent
but can not do.
I am creating an application that intercepts an sms via BroadcastReceiver
, but from that I want to receive a sms via broadcast
open service
. probably this is done via Intent
but can not do.
You only need to start the service on the onReceive of the class that implements BroadcastReceiver:
import meu.pacote.com.o.servico.MinhaClasseServico;
import android.content.Context;
import android.content.Intent;
import android.content.BroadcastReceiver;
public class MeuBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent serviceIntent = new Intent(this, MinhaClasseServico.class);
context.startService(serviceIntent);
}
}