资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

android双屏,android双屏收银

Android 双屏异显副屏拉伸怎么解决?

如果是厂商定制系统,可以在设置(厂商可能提供相应的调整界面)中或开发者选项里进行调整

成都创新互联公司成立与2013年,是专业互联网技术服务公司,拥有项目做网站、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元金寨做网站,已为上家服务,为金寨各地企业和个人服务,联系电话:13518219792

android双屏无法弹出系统键盘

原因是因为当界面初始化的时候可能EditText并没有初始化完成,就要求显示软键盘了。

在包含EditText外层布局上添加,抢在EditText获取焦点,即可。

正常情况下,只要写了EditText控件,当进入Activity时,是会直接显示软键盘的,但是如果我们的EditText是GONE或者INVISIBLE的话,当我们点击其他控件,然后让Edittext显示,并且弹出软键盘,那么这个时候就必须关注顺序的问题,必须必须先让EditText显示,在调用显示软键盘的代码才可以,如果先让软键盘弹出再让EditText显示,这个时候软键盘是弹不出来的。

2018-01-29 关于Android Studio 在第二屏关掉后 只有一屏时 打开不显示

Android Studio 有一个很好的功能 在你关掉项目后 会记录你窗口的位置 大小 等下次打开的时候 又回到原样 多大就多大 位置在哪就在哪 尴尬的是 如果你在公司用双屏 回家 只有一屏工作的时候 打开 就看不到窗口了

这个时候 之前只能打开一个项目 然后再 打开你要打开的项目 选择 this window 才行 但这样很麻烦

其实 在项目 目录 .idea/workspace.xml

就是记录 屏幕位置的 修改再打开就可以了

android 双屏异显,指定activity显示在副屏

原来实现双屏异显完全是这东东起的作用.在此记录一下学习的笔记,供后续参考... activity 的 context. 辅助显示屏的内容:

Android8.0双屏显示异常,主屏启动的Activity会显示到副屏上的问题

问题现象:

由于设备有两个Display设备,分为主屏和副屏,正常情况下startActivity如果不指定displayId的话,都会默认显示在主屏上,但是在某些情况下launcher启动的应用Activity会显示到副屏上面去。

根据现象来分析,初步判断问题原因是startActivity的流程出现异常导致的,那么就需要从startActivity流程开始查找原因。

先看framework\base\services\core\java\com\android\server\am\ActivityStarter.java中的:

```

int startActivityLocked(IApplicationThread caller, Intent intent, Intent ephemeralIntent,

       ...) {

    ...

    mLastStartActivityResult = startActivity(caller, intent, ephemeralIntent, resolvedType,

            aInfo, rInfo, voiceSession, voiceInteractor, resultTo, resultWho, requestCode,

            callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags,

            options, ignoreTargetSecurity, componentSpecified, mLastStartActivityRecord,

            inTask);

    ...

}

```

一步一步往下查之后看到startActivityUnchecked函数中有对task和stack的变更与displayId相关的操作,重点看这个地方:

// Note: This method should only be called from {@link startActivity}.

private int startActivityUnchecked(final ActivityRecord r, ActivityRecord sourceRecord,

        IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,

        int startFlags, boolean doResume, ActivityOptions options, TaskRecord inTask,

        ActivityRecord[] outActivity) {

...

// Should this be considered a new task?

    int result = START_SUCCESS;

    if (mStartActivity.resultTo == null mInTask == null !mAddingToTask

            (mLaunchFlags FLAG_ACTIVITY_NEW_TASK) != 0) {

        newTask = true;

        String packageName= mService.mContext.getPackageName();

        if (mPerf != null) {

            mStartActivity.perfActivityBoostHandler =

                mPerf.perfHint(BoostFramework.VENDOR_HINT_FIRST_LAUNCH_BOOST, packageName, -1, BoostFramework.Launch.BOOST_V1);

        }

        result = setTaskFromReuseOrCreateNewTask( 

                taskToAffiliate, preferredLaunchStackId, topStack);

    } else if (mSourceRecord != null) {

        result = setTaskFromSourceRecord(); //在添加打印后发现出现问题的时候是走的这个函数进行task与stack操作的

    } else if (mInTask != null) {

        result = setTaskFromInTask();

    } else {

        // This not being started from an existing activity, and not part of a new task...

        // just put it in the top task, though these days this case should never happen.

        setTaskToCurrentTopOrCreateNewTask();

    }

...

}

那么就看setTaskFromSourceRecord这个函数干了些什么:

private int setTaskFromSourceRecord() {

...

    // We only want to allow changing stack in two cases:

    // 1. If the target task is not the top one. Otherwise we would move the launching task to

    //    the other side, rather than show two side by side.

    // 2. If activity is not allowed on target display.

    final int targetDisplayId = mTargetStack != null ? mTargetStack.mDisplayId

            : sourceStack.mDisplayId;

final boolean moveStackAllowed = sourceStack.topTask() != sourceTask

            || !mStartActivity.canBeLaunchedOnDisplay(targetDisplayId);

if (moveStackAllowed) {

        mTargetStack = getLaunchStack(mStartActivity, mLaunchFlags, mStartActivity.getTask(),

                mOptions);

        // If target stack is not found now - we can't just rely on the source stack, as it may

        // be not suitable. Let's check other displays.

        if (mTargetStack == null targetDisplayId != sourceStack.mDisplayId) {

            // Can't use target display, lets find a stack on the source display.

            mTargetStack = mService.mStackSupervisor.getValidLaunchStackOnDisplay(

                    sourceStack.mDisplayId, mStartActivity);

        }

        if (mTargetStack == null) {

            // There are no suitable stacks on the target and source display(s). Look on all

            // displays.

            mTargetStack = mService.mStackSupervisor.getNextValidLaunchStackLocked(

                    mStartActivity, -1/* currentFocus */);

        }

    }

}

根据注释来看,关键就是这个moveStackAllowed了,打印log发现出现问题的时候moveStackAllowed 为true,所以会对mTargetStack 进行重新赋值的操作,在重新赋值操作过程中,由于当前topTask所在的stack是副屏的,所以会进入mService.mStackSupervisor.getNextValidLaunchStackLocked查找非-1的displayId对应的ActivityStack来赋值。

/**

* Get next valid stack for launching provided activity in the system. This will search across

* displays and stacks in last-focused order for a focusable and visible stack, except those

* that are on a currently focused display.

*

* @param r The activity that is being launched.

* @param currentFocus The display that previously had focus and thus needs to be ignored when

*                    searching for the next candidate.

* @return Next valid {@link ActivityStack}, null if not found.

*/

ActivityStack getNextValidLaunchStackLocked(@NonNull ActivityRecord r, int currentFocus) {

    mWindowManager.getDisplaysInFocusOrder(mTmpOrderedDisplayIds);

    for (int i = mTmpOrderedDisplayIds.size() - 1; i = 0; --i) {

        final int displayId = mTmpOrderedDisplayIds.get(i);

        if (displayId == currentFocus) {

            continue;

        }

        final ActivityStack stack = getValidLaunchStackOnDisplay(displayId, r);

        if (stack != null) {

            return stack;

        }

    }

    return null;

}

从getNextValidLaunchStackLocked内部可以看到按照displayId由小到大的顺序依次添加到mTmpOrderedDisplayIds这个列表中去,然后再由大到小依次遍历mTmpOrderedDisplayIds非-1的displayId对应的ActivityStack,由于设备的主屏和副屏的displayId分别是0、1,所以最先查到的就是displayId为1的ActivityStack,这样activity就会显示到副屏对应的ActivityStack上,从而导致默认启动的activity在副屏上显示的问题。

知道原因就好办了,直接在setTaskFromSourceRecord中添加判断:

if (mTargetStack == null) {

            // There are no suitable stacks on the target and source display(s). Look on all

            // displays.

            ActivityStack topStack = mSupervisor.mFocusedStack;

            int currentFocusDisplayId = -1;

            //如果topStack对应的displayId不等于startActivity传入的targetDisplayId,那么就在getNextValidLaunchStackLocked中传入topStack.mDisplayId排除掉对应的topStack就行了。

            if (topStack != null topStack.mDisplayId != targetDisplayId) {

                currentFocusDisplayId = topStack.mDisplayId;

            }

            mTargetStack = mService.mStackSupervisor.getNextValidLaunchStackLocked(

                    mStartActivity, currentFocusDisplayId /* currentFocus */);

        }

请教Android 5.1 双屏异显

1.修改frameworks\base\core\res\res\values\config.xml中config_lidOpenRotation的值为90。2.修改frameworks\base\services\core\java\com\android\server\wm\WindowManagerService.java中:intmRotation=1;3.修改frameworks\native\services\surfaceflinger\DisplayDevice.cpp里面:setProjection(DisplayState::eOrientation90,mViewport,mFrame);4、交换一下Bootanimation里面的h和w


本文名称:android双屏,android双屏收银
文章网址:http://cdkjz.cn/article/dsdisgs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220