Reputation: 140
I have a service Class in android. Is it be possible for a Service to run as a separate process than an application just for receiving SMS and enqueue them in a queue after that an application reads SMS from this Queue.
Is it possible to launch a separate service?
I have tag the source code of SmsService class below
public class SmsService extends Service {
private SMSReceiver mSMSreceiver;
private IntentFilter mIntentFilter;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
public SmsService(){
/*dba = new DataBaseAdapter(this);*/
mSMSreceiver = new SMSReceiver();
}
@Override
public void onCreate(){
super.onCreate();
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(ConstantClass.SMS_RECEIVED);
registerReceiver(mSMSreceiver,mIntentFilter);
}
@Override
public int onStartCommand(Intent intent , int flags, int type){
return START_STICKY;
}
@Override
public void onDestroy(){
super.onDestroy();
//unregisterReceiver(mSMSreceiver);
}
Upvotes: 2
Views: 733
Reputation: 68177
To enroll your service in a different process, you need to define android:process
attribute when defining your service in AndroidManifest.xml
For example:
<service android:process=":kaushik" />
This will run your service in a new process called kaushik.
Upvotes: 2