Reputation: 3
I have a problem with this part of code
Intent myactivity = new Intent(context, MyKeyboard.class);
myactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myactivity);
if i put it in the "if" there isn' t any response but if i put it outside it works
public class OutgoingCallReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if(null == bundle) return;
String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if( phonenumber=="11111111111" ) {
Intent myactivity = new Intent(context, MyKeyboard.class);
myactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myactivity);
}
}
}
Upvotes: 0
Views: 100
Reputation: 34765
phonenumber=="11111111111"
replace the above line with below and try
phonenumber.equals("11111111111")
Upvotes: 4