Is it possible to open an android app when I get a message? If possible, is there an option only if it's a specific number that sends the message, and then open the app? Or, another option when you open the message then open the app?
Asked
Active
Viewed 90 times
0
-
You can register a broadcast receiver on incoming messages [link](http://stackoverflow.com/questions/4117701/android-sms-broadcast-receiver), pull info from the message, and decide if you need to launch your app. – AndroidEx Apr 04 '15 at 21:13
-
I don't understand did u can explain again? – Oster Apr 05 '15 at 04:38
-
Well, you'll have to look into how broadcast receivers work. That link above gives a good example relevant to your case, also you can use official [references](http://developer.android.com/reference/android/content/BroadcastReceiver.html) and other sources. But in short, the system broadcasts intents when certain events happen (e.g., incoming text message), and you can register a broadcast receiver to intercept these intents containing additional info about the events. In `BroadcastReceiver.onReceive` method you can do whatever you like, for example launch an activity of your app. – AndroidEx Apr 05 '15 at 04:51
2 Answers
0
That's not possible. You can send notifications but the user is who open the app touching the notification.

Camilo Sacanamboy
- 630
- 1
- 9
- 23
-
And how I can send notification when the user open a message from specific number? – Oster Apr 05 '15 at 04:40
0
Using below code you can detect the incoming message and can open your activity on specific message. if you are using this code then make sure you are registering this receiver in your menifest with action. And also add Permission to detect incoming message.
public class BroadCast extends BroadcastReceiver{
@Override
public void onReceive(Context arg0, Intent arg1) {
Bundle b=arg1.getExtras();
if(b!=null)
{
String state = b.getString(TelephonyManager.EXTRA_STATE);
String phoneNumber = b.getString(Intent.EXTRA_PHONE_NUMBER);
if(phoneNumber.equalsIgnoreCase("Mobile Number"))
{
Intent in=new Intent(arg0, YourActivity.class);
in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
arg0.startActivity(in);
}
}
}
}

Prashant Bhoir
- 900
- 6
- 8