Android:从应用切换回Chrome [英] Android: Switch back to Chrome from app

查看:64
本文介绍了Android:从应用切换回Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android平板电脑上有一个网络链接,单击该链接可在全屏模式下运行Chrome.

I have a weblink on the android tablet that when clicked, runs Chrome full screen.

在该网站上,我可以单击一个链接并打开我的应用程序(在Android Studio中开发).但是,一旦该应用打开,我希望它立即将焦点发送回Chrome.我见过有人在这个论坛上说过,有一种方法可以切换任务,但是他们没有提供代码或链接.

In that website, I can click a link and open my application (developed in Android Studio). But once that app is opened, I want it to immediately send focus back to Chrome. I've seen people say on this forum there is a way to switch tasks, but they didn't provide code or links on how to do it.

或者我也可以从任务管理器中禁用我的应用程序(但仍然可以运行它),这也许也是件好事吗?

Or disabling my app from the task manager (but still have it run) would be good too I maybe?

我想做的是从Chrome网站向应用程序发送启动和停止命令.即第一次,它将打开并启动"应用程序执行某项操作.应用保持打开状态,直到从网站收到停止"命令为止.过程重复.

What I am trying to do is send start and stop commands to the application from the Chrome website. i.e. 1st time, it opens and 'starts' the app doing something. App stays open and does it's thing until it receives a 'stop' command from the website. Process repeats.

我已经在onResume函数中尝试了意图的getdata,但是由于该应用在调用后不会将焦点"发送回网站,因此Chrome下次发送数据时不会调用onResume.该应用程序是不可见的",因此在打开该应用程序时,用户甚至在不知道已打开应用程序的情况下继续浏览Chrome网站.但是就像我说的那样,即使他们继续在Chrome中使用,但实际上现在的重点是另一个应用程序.有点奇怪

I have tried the intent's getdata within the onResume function, but since the app doesn't send 'focus' back to the website after it is called, onResume isn't called the next time Chrome sends data to it. The app is 'invisible', so when it is opened, the user continues within the Chrome website without even knowing an app has been opened. But like I said, even though they are continuing within Chrome, the actual focus is now on the other app. It's kind of weird.

所以,这有点不同,我必须切换回一个已经打开的Chrome链接,而不仅仅是Chrome.如果您知道我的意思,

So, this is a little different in that I have to switch back to an already opened Chrome link, not simply just Chrome..if you know what I mean.

对于在我的应用程序中以编程方式执行此操作的任何帮助,我们深表感谢.

Any help on how to do this programmatically within my app is appreciated.

推荐答案

发现了这一点,该方法有效:

found this, which works:

super.onBackPressed();

super.onBackPressed();

这篇关于Android:从应用切换回Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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