Mohammad H
Mohammad H

Reputation: 805

How can I do something (like starting my 2nd activity) when user enable's wifi even when my app is not open?

I am totally confused how to perform this action. I found several ways but no answer. please help me with some code or project. I want my activity starts anywhere I turn on Wifi even when my app is not open.

Upvotes: 1

Views: 36

Answers (1)

momoja
momoja

Reputation: 938

You know, you already have a clue on what you will do, so googling it would be really easy. I suggest referring to some SO questions and answers and going to developer.android.com to browse the documentation. basically you want to:

  1. Start a service on boot, that listens for when the wifi is turned on/off.
  2. Create and send a broadcast to your app
  3. Define a BroadcastReceiver that launches your app or another intent

Upvotes: 1

Related Questions