Is there a way to receive broadcasts(like sms notification) in stopped application?
Actually it works simply in lower than Android 3.1.
EDIT 1:
Thanks to @Squonk for comment.
So my questions is, is it REALLY impossible? you can check PlanB app in market which does this things.
EDIT 2:
this is my broadcast receiver. The onReceive function is never called(when application is stopped).
public class SmsReciever extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
Log.e("kpav", "kpav");
String url = "http://www.google.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(32);
i.setData(Uri.parse(url));
arg0.startActivity(i);
}
}
For Android v3.1 onwards, any app which has been manually started at least once by the user, will receive broadcasts that it has registered in the manifest even after a reboot.
BUT…the user must have manually started that app – it’s not possible for an app to be installed and have it automatically receive broadcasts otherwise.
Also, if the user manually uses ‘Force Stop’ from the Settings on a device, it will no longer receive broadcasts until the user manually starts the app again.
So basically, in answer to your question…
…the answer is no except under the circumstances I describe above.