search
HomeJavaOpen application from foreground service when application is closed

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):

Intent i = getFeatureManager().getMainMenu().getMainActivity().getPackageManager().
                getLaunchIntentForPackage(getSettingByName("Launch Package").getSValue());

        if (i == null) {
            return;
        }
        getFeatureManager().getMainMenu().getMainActivity().startActivity(i);

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:

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

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
This article is reproduced at:stackoverflow. If there is any infringement, please contact admin@php.cn delete

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 agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.