Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open app when connect with wifi

How can I open my application when an user enters a zone that has wi-fi? Is this possible? Suppose my application is onPause() state (means My Device's homescreen). now when device connected with wifi. it will automatically open my application.

like image 217
Bhavesh Jethani Avatar asked Feb 26 '13 11:02

Bhavesh Jethani


People also ask

How do I control apps using Wi-Fi?

In the Android Mobile network settings, tap on Data usage. Next, tap on Network access. Now you see a list of all your installed apps and checkmarks for their access to mobile data and Wi-Fi. To block an app from accessing the internet, uncheck both boxes next to its name.

How can I use my phone while connected to Wi-Fi?

To do this, swipe down on your notification bar and check that the mobile data toggle is switched on. Or go into “Settings,” tap “Connections,” and “Data Usage” and make sure that mobile data is switched on. Step 2: Connect to a Wi-Fi network. Tap “Settings,” then “Connections”, then “Wi-Fi” and flip the switch on.

What does open mean on Wi-Fi?

An open wireless network is one that does not have any wireless security protocol running on it. When you see your device's list of wireless access points, these will show up with saying “open” instead of “secure” or the padlock icon is missing.

How can I open hotspot when connected to Wi-Fi?

Navigate to Settings > Network & internet > Hotspot & tethering. Here, you can select to share a connection via Wi-Fi, USB, or Bluetooth. For a Wi-Fi connection, tap Wi-Fi hotspot and toggle it on. The hotspot name will be displayed on this screen.


1 Answers

Try add broadcast receiver and listen network changes, when wi-fi connected start your activity. Something like this solution

public class ConnectivityReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

                ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
                NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
                if (((null != wifi)&&(wifi.isAvailable())) || ((null != mobile)&&(mobile.isAvailable()))){
                    Intent uplIntent = new Intent(context, YourActivity.class);
                    uplIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(uplIntent);
                }

    }
}

And add to manifest

    <receiver android:name=".receiver.ConnectivityReceiver">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
        </intent-filter>
    </receiver>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
like image 183
prozhyga Avatar answered Sep 21 '22 21:09

prozhyga