I'm trying to create an application that, when the phone receives an incoming SMS, reads its contents plus the number and writes it to its database . The application receives information about the receipt of SMS through
BroadcastReceiver , working in the background.
The following is required: the application must recover after the system kills it due to lack of resources.
How to implement it?
Add to onCreate of your main activity:
intent = PendingIntent.getActivity(YourApplication.getInstance().getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags());
AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000, intent); System.exit(2);