It's possible to auto-start android application when a specified event, different by BOOT_COMPLETE, is triggered?
For example i want automatically start my app when a connection is available or when there is an incoming call.
I tried to start my application on SMS received. I'm able to capture the event when my app is running obv but when my app is off the event is not captured and my app not start. Where i wrong?
Manifest:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<receiver
android:name="com.whatsapp.raj.MyBCast"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
</application>
Receiver:
public class MyBCast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
Log.wtf("BCAST", "Connectivity changed!");
Intent pushIntent = new Intent(context, MainActivity.class);
context.startService(pushIntent);
}
}