AndroidScreenShot_SysApi icon indicating copy to clipboard operation
AndroidScreenShot_SysApi copied to clipboard

不能后台截图

Open 31884780 opened this issue 6 years ago • 5 comments

切换到后台延时截图时会直接跳转回到app主界面,截到的不是想要的

31884780 avatar Sep 25 '19 12:09 31884780

你看下为何回到app主界面,如果我没有主动后台,请手动按下home键。

BruceWind avatar Sep 25 '19 14:09 BruceWind

切换到后台延时截图时会直接跳转回到app主界面,截到的不是想要的

launchmode 改为singleinstance

RealMoMo avatar Aug 17 '20 08:08 RealMoMo

@RealMoMo 这个是您目前关于跳转回到app主界面的解决方案?? Is it your solution about jump back to app?

BruceWind avatar Aug 17 '20 08:08 BruceWind

这个是您目前关于跳转回到app主界面的解决方案?? Is it your solution about jump back to app?

估计题主,和我一样,只用screenshot lib,自己写demo。增加个mainactivity,但没有主动finish。所以,回到后台截图后,因为没有指定launchmode,所有activity在同一个activity栈,而截图activity是透明的,所以截图到主界面。 操作打开app,回到主页 直接adb启动screenshot activity,确实截图主页面。修改lauchmode,运行另一个activty栈就正常了。 当然,没有打开其他activity界面,用service截图是正常的。 最好lib 增加screenshotactivity,launchermode就好了。

RealMoMo avatar Aug 17 '20 08:08 RealMoMo

哦哦,我demo里的ScreenShotService.java用的是FLAG_ACTIVITY_NEW_TASK.

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                //这里启动新的透明的activity后 上个页面的dialog 键盘可能会因为页面pause而隐藏.
                Intent i = new Intent(ACTION_SHOTER);
                // 这个不是必需的
                i.addCategory(Intent.CATEGORY_DEFAULT);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);
            }
        }, 4200);

BruceWind avatar Aug 17 '20 08:08 BruceWind