我对这部分代码有疑问
Intent myactivity = new Intent(context, MyKeyboard.class);
myactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myactivity);
如果我把它放在“如果”中没有任何反应,但如果我把它放在外面它就可以了
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);
}
}
}