app/src/main/java/ad1024/uw/sms2email/SMSTransferService.java
package ad1024.uw.sms2email;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import java.util.Date;
import java.util.Properties;
import java.util.regex.Pattern;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
public class SMSTransferService extends Service {
private SMSObserver mObserver;
public SMSTransferService() {
}
@Override
public void onCreate() {
mObserver = new SMSObserver(new Handler(), this);
Log.i("SMSService", "Started");
getContentResolver().registerContentObserver(Uri.parse("content://sms/"),
true, mObserver);
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
super.onDestroy();
Log.i("SMSService", "Destroyed");
getContentResolver().unregisterContentObserver(mObserver);
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
}