Faizan Ahmad
Faizan Ahmad

Reputation: 362

How to open your own app from background programmatically in android?

I am working on an app in which I implemented sockets. Due to some requirements I want to open my app from background programmatically. Basically, background service is running there, now whenever I am receiving an emit (from sockets), I have to open my app, i am unable to do this. My code is not working for android version 10 or above (working fine for 9 or below).

protected Emitter.Listener onNewEmit = new Emitter.Listener() {
    @Override
    public void call(Object... args) {
          startActivity(getIntent().addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)); 
//this solution is working for android version 9 or below (not for android versions > 9)

                                        //I have to open my app here
    }
};

I am running background service too in my app and implemented code is working fine for android version 9 or below.

Upvotes: 1

Views: 402

Answers (0)

Related Questions