Android WindowManager无法传输触摸焦点

时间:2016-08-10 06:46:25

标签: android view drag-and-drop android-windowmanager

有没有人遇到过这个错误

1535-2103/system_process E/WindowManager: Unable to transfer touch focus

我尝试做的是从LongClick触发/委托PopupWindow事件到基础视图startDrag()

基础视图中的代码(将被拖动的视图)

@Override
    public boolean onLongClick(View v) {
        if (!isDragAllowed()) {
            return false;
        }

        startDrag(v);

        dragAllowed = false;

        return false;
    }

UI layout

但是startDrag()被调用时始终会显示以上错误,而startDrag()本身始终会返回false

我知道导致结果的流程startDrag()内的performDrag()方法false

    public final boolean startDrag(ClipData data, DragShadowBuilder shadowBuilder,
                Object myLocalState, int flags) {

            ...

                    //THIS ALWAYS RETURN FALSE
                    okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, token,
                            shadowSize.x, shadowSize.y,
                            shadowTouchPoint.x, shadowTouchPoint.y, data);
                    if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "performDrag returned " + okay);

                    // Off and running!  Release our local surface instance; the drag
                    // shadow surface is now managed by the system process.
                    surface.release();
                }
            } catch (Exception e) {
                Log.e(VIEW_LOG_TAG, "Unable to initiate drag", e);
                surface.destroy();
            }

            return okay;
        }

但遗憾的是,由于该方法是IWindowSession的成员,我不知道该课程在哪里

0 个答案:

没有答案