且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

推电话屏幕背景,同时拨打电话

更新时间:2022-10-15 14:57:40

我认为你需要使用一个活动来显示呼叫屏幕上的东西的顶部。一个对话框将无法正常工作,因为你是显示从本次活动,您已经贴吧,但一旦你开始呼叫意图本次活动将不会对堆栈的顶部了。

在这里看到了答案:Android - 如何在一个本机屏幕显示一个对话框

你如何风格你的(新)活动看起来像一个对话框,虽然,这将给你相同的视觉效果你是后。

一旦你创建一个使用在该问题所示的参数一个新的活动,那么你可以在启动callIntent后startActivity启动

 公共无效MakeCall函数(查看视图){
    尝试{
        意图callIntent =新意图(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse(电话:NUMBER));
        startActivity(callIntent);
        Toast.makeText(这一点,TEST,Toast.LENGTH_LONG).show();        可运行showDialogRun =新的Runnable(){
            公共无效的run(){
                意图showDialogIntent =新意图(这一点,DialogActivity.class);
                startActivity(showDialogIntent);
            }
        };
        处理程序H =新的处理程序();
        h.postDelayed(showDialogRun,2000年);
    }赶上(ActivityNotFoundException activityException){
        抛出E = NULL;
        Log.e(helloandroid拨号榜样,Callfailed,E);
    }
}

这是一两秒钟延迟对话框startActivity似乎使其更容易真正在手机屏幕上方飞溅。

We're using an android application to do some assessments, when an assessor arrives on site they need to login with the office on the call. Theres a reference number I'd really like to be able to keep on the phone display once they ring in.

What would be perfect is a dialog that says the number on top of the dialer screen.

I've tried to do this, but it just overtakes the dialog and shows the calling screen. Is there anyway to push the dialer to the background and continue to show the user the dialog?

Heres what I have so far:

public void makecall(View view){ 
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:NUMBER"));
        startActivity(callIntent);
        Toast.makeText(getApplicationContext(), "TEST",Toast.LENGTH_LONG).show(); 
        AlertDialog.Builder adb = new AlertDialog.Builder(this); 
        adb.setTitle("Alert"); 
        adb.setMessage("Client Reference Blah Blah");
        adb.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
            public void onClick(DialogInterface dialog, int id) { 

            } 
        });
        adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
            public void onClick(DialogInterface dialog, int id) { 
                dialog.cancel(); 
            }
        });
        adb.show();         
    } catch (ActivityNotFoundException activityException) {
        Throwable e = null;
        Log.e("helloandroid dialing example", "Callfailed", e); 
    }
}

I think you need to use an activity to show something over top of the in call screen. A dialog will not work since you are showing it from this activity that you've posted, but this activity won't be on top of the stack any more once you start the call intent.

See the answer here: Android - How to display a dialog over a native screen?

for how you can style your (new) activity to look like a dialog though, which will give you the same visual effect you are after.

Once you create a new activity using the parameters shown in that question then you can start it with startActivity after you start the callIntent

public void makecall(View view){ 
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:NUMBER"));
        startActivity(callIntent);
        Toast.makeText(this, "TEST",Toast.LENGTH_LONG).show(); 

        Runnable showDialogRun = new Runnable() {
            public void run(){
                Intent showDialogIntent = new Intent(this, DialogActivity.class);
                startActivity(showDialogIntent);
            }
        };
        Handler h = new Handler();
        h.postDelayed(showDialogRun, 2000);
    } catch (ActivityNotFoundException activityException) {
        Throwable e = null;
        Log.e("helloandroid dialing example", "Callfailed", e); 
    }
}

Delaying the dialog startActivity by a second or two seems to make it more likely to actually splash on top of the phone screen.