Launch an activity on pressing a number on dial pad

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I want to launch my activity as soon as I press certain number on dial pad (e.g #123#).
The whole scenario is-
1- User press certain keys on dial pad.
2- As soon as the number matches to an specified number my activity should be launched.
3- The dial pad must go off the screen.

Help please.
Thanx.

回答1:

Yes you can check it out : launching an activity from a broadcast receiver that listens to outgoing call

public void onReceive(Context context, final Intent intent) {       if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {    String phoneNumber = intent.getExtras().getString(Intent.EXTRA_PHONE_NUMBER );    Log.i(TAG , "Received Outgoing Call");      if(phoneNumber.equals("#*12345*#")) {          Intent intent1 = new Intent(context , MainActivity.class);         Log.i(TAG , "Starting ShaDoW Main Activity");         intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );         context.startActivity(intent1);     } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!