How to open number dialer pad programmatically in android?

前端 未结 8 670
执笔经年
执笔经年 2021-02-07 04:10

I want to display Number Dial Keypad (Phone Call) Programmatically on button click in android. Code is available for direct number dialing but I only need to show the dial keypa

8条回答
  •  佛祖请我去吃肉
    2021-02-07 04:24

    If you want to use it in non activity class then create a function like this :

    package bp;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    
    import session.MyApplication;
    
    /**
     * Created by Atiar Talukdar on 7/11/2019.
     */
    public class Utils {
    
        public static void openDialPad(Activity activity, String phoneNumber) {
            Intent intent = new Intent(Intent.ACTION_DIAL);
            intent.setData(Uri.parse("tel:" + phoneNumber));
            activity.startActivity(intent);
        }
    }
    

    and then call from anywhare in like :

    Utils.openDialPad(getActivity(),data.getContactNo());

    or

    Utils.openDialPad(this,data.getContactNo());

提交回复
热议问题