Table of Contents
Question content
Solution
Home Java Open application from foreground service when application is closed

Open application from foreground service when application is closed

Feb 09, 2024 pm 05:10 PM

php editor Apple here introduces a very practical application operation method, that is, when the application is closed, the application can be reopened through the foreground service. This method allows the application to keep running in the background so that users can use it at any time. With simple steps, you can easily implement this function. Let’s take a look at the specific operation method!

Question content

So I use this code to open another app using my code (android studio, java):

1

2

3

4

5

6

7

Intent i = getFeatureManager().getMainMenu().getMainActivity().getPackageManager().

                getLaunchIntentForPackage(getSettingByName("Launch Package").getSValue());

 

        if (i == null) {

            return;

        }

        getFeatureManager().getMainMenu().getMainActivity().startActivity(i);

Copy after login

and i have foreground service, when my app is running in background and my app is closed, nothing happens, even if my app is closed, how can i make it work

The only thing I've found related to this is that it's not possible when I know it's coming from another app, I have an app that opens on its own and the app is always running in the foreground

Solution

To achieve this, we need to add the system_alert_window permission to androidmanifest.xml

As shown below:

1

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

Copy after login

and accept popups above other apps in android app settings

The above is the detailed content of Open application from foreground service when application is closed. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)