自定义对话框隐藏在另一个活动的后面 [英] custom dialog box hides behind another activity

查看:128
本文介绍了自定义对话框隐藏在另一个活动的后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android新手.目前正在使用"truecaller"之类的来电显示应用.我显示呼叫日志屏幕,并单击呼叫日志条目(它是linearlayout),然后呼叫Action_Call意图.

I am new to android. Currently working on Caller Id app like 'truecaller'. I am showing call log screen and on click of Call log entry (which is linearlayout) I am calling Action_Call intent.

private View setList(int position, ViewGroup parent) {
        LayoutInflater inf = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        final View row = inf.inflate(R.layout.liststyle, parent, false);

        TextView tvName = (TextView) row.findViewById(R.id.tvNameMain);
        final TextView tvNumber = (TextView) row.findViewById(R.id.tvNumberMain);
        TextView tvTime = (TextView) row.findViewById(R.id.tvTime);
        TextView tvDate = (TextView) row.findViewById(R.id.tvDate);
        //TextView tvType = (TextView) row.findViewById(R.id.tvType);
        ImageView tvImageView = (ImageView) row.findViewById(R.id.tvTypeImage);

        final LinearLayout callLogLayout = (LinearLayout) row.findViewById(R.id.callLogLayout);
        callLogLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final int REQUEST_PHONE_CALL = 1;
                String Number = tvNumber.getText().toString();
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                if ( ContextCompat.checkSelfPermission( row.getContext(), Manifest.permission.CALL_PHONE ) != PackageManager.PERMISSION_GRANTED ) {

                    ActivityCompat.requestPermissions( CallLogActivity.this, new String[] {  android.Manifest.permission.CALL_PHONE  },
                            REQUEST_PHONE_CALL );
                }
                callIntent.setData(Uri.parse("tel:" + Number));
                startActivity(callIntent);
            }
        });

屏幕如下所示.

我的问题是自定义呼叫者ID对话框",当我开始拨出电话时显示在上面的屏幕(呼叫日志屏幕)上,而在实际呼叫"屏幕上却没有显示.

My Problem is 'Custom Caller ID Dialog box' which I am showing when outgoing call get started gets stick to above screen (call log screen) and not showing it on Actual Call screen.

当我单击下面的屏幕上的呼叫记录"条目时.

When I click on Call Log entry below screen pops up.

当我单击结束通话按钮时,我会看到自定义对话框.

When I click end call button then I can see custom dialog box.

OnCallStateChanged

OnCallStateChanged

case TelephonyManager.CALL_STATE_OFFHOOK:
            //Transition of ringing->offhook are pickups of incoming calls.  Nothing done on them
            if (lastState != TelephonyManager.CALL_STATE_RINGING) {
                isIncoming = false;
                callStartTime = new Date();
                contactName = CallSmsDetector.retrieveContactName(context, savedNumber);
                // CallSmsDetector.startRecording(context);
                mCallListener.onOutgoingCallStarted(context, savedNumber, callStartTime, contactName);
                //mCallListener.onOutgoingCallEnded(context,savedNumber,callStartTime,contactName);
            } else {
                isIncoming = true;
                callStartTime = new Date();
                contactName = CallSmsDetector.retrieveContactName(context, savedNumber);
                // CallSmsDetector.startRecording(context);
                // mCallListener.onIncomingCallAnswered(context, savedNumber, callStartTime, contactName);
                //mCallListener.onIncomingCallEnded(context,savedNumber,callStartTime,contactName);
            }
            break;

OnOutgoingCallStarted

OnOutgoingCallStarted

public void onOutgoingCallStarted(Context ctx, String number, Date start, String contactName)
        {
            //popup(contactName, number);
            cName = contactName;
            Log.e("onOutgoingCallStarted","onOutgoingCallStarted");
            if(contactName==""){
                Intent i=new Intent(ctx,PopupActivity.class);
                i.putExtra("DATAPASSED",number);
                Log.e("number",number);
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);

            }
            else
            {
                Log.e("Contact number",contactName);
                Intent i=new Intent(ctx,PopupActivity.class);
                i.putExtra("DATAPASSED",contactName);
                i.putExtra("Number",number);
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);

            }

            Log.e("outgoing call started", number);

        }

是否需要延迟?我没有任何头绪.

Does it require delay? I am not getting any clue.

更新每当我在代码中放置断点时,它出奇地完美地工作.

UPDATE Whenever I put breakpoint in code, surprisingly it works perfectly.

我什至试图拖延但没有运气.

I have even tried to put delay but no luck.

推荐答案

在我看来,您有上下文问题.我在getActivity()中传递时多次遇到此问题,并且弹出菜单出现在我的activity后面.我想如果您将setList()的第一行更改为

It seems to me that you have a context problem . I have faced this issue many times where I passed in getActivity() and the popup menu appeared behind my activity. I think if you change the first line in setList() to

 LayoutInflater inflater = LayoutInflater.from(parent.getContext());

应该可以正常工作. 尝试让我知道.

should work fine. Try and let me know.

这篇关于自定义对话框隐藏在另一个活动的后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆