Android - 通过呼叫按钮(绿键)将 Activity 带到前台

发布于 2024-08-20 09:34:50 字数 113 浏览 1 评论 0原文

我目前有一个应用程序,当按下主页键时,它会自然地被推送到后台。

该活动失去焦点,但继续在后台运行。

所以我想知道当用户按下设备上的绿色键(通话按钮)时是否可以将应用程序带回到前台?

I currently have an application that naturally gets pushed to the background when the home key is pressed.

The activity losses focus but continues running in the background.

So I want to know is it possible to bring the application back to the foreground when the user presses the green key (call button) on the device?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城已无爱 2024-08-27 09:34:50

如果没有用户交互,则无法完全覆盖呼叫按钮行为。按下它时,系统将要求用户在默认操作(启动拨号器)或启动应用程序之间进行选择。

如果您想这样做,您的清单将如下所示:

<activity android:name=".SomeActivity">
    <intent-filter>
        <action android:name="android.intent.action.CALL_BUTTON" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

There is no way to completely override the call button behaviour without user interaction. When pressing it, the user will be asked to choose between the default action (launching the dialer), or launching your application.

If you wanted to do this, your manifest would look something like this:

<activity android:name=".SomeActivity">
    <intent-filter>
        <action android:name="android.intent.action.CALL_BUTTON" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文