0

我对这部分代码有疑问

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);


                }      

        }

}
4

1 回答 1

6
phonenumber=="11111111111"

用下面替换上面的行并尝试

phonenumber.equals("11111111111")
于 2012-04-26T18:00:12.200 回答