我正在学习通过拨号盘启动我的应用程序。我正在使用以下代码。用于拨号盘启动应用程序(在广播接收器中)
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle bundle = intent.getExtras();
if (null == bundle)
return;
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
//here change the number to your desired number
String compare_num="5556";
if(phoneNumber.equals(compare_num))
{
setResultData(null);
// Guardian.changeStealthMode(context,PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
//Intent to move to next Activity
Intent myintent=new Intent(context,MainActivity.class);
myintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myintent);
// abortBroadcast();
以及包含主要活动的启动应用程序
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//Intent call here
Intent intent=getIntent();
String message = intent.getStringExtra(MainActivity.TELEPHONY_SERVICE);
//text here
EditText et = (EditText) findViewById(R.id.editText1);
//Button here
Button Login = (Button) findViewById(R.id.button1);
}
当我启动此代码时,我的应用程序不会通过拨号盘启动。请帮帮我.........