Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No connectivity change with VPN?

Tags:

android

Is there a way to get notified when a VPN is connected or disconnected? Because of what I see, the ConnectivityManager does not broadcast any intent about that.

I also tried (unsuccessfully) to register to the hidden ACTION_VPN_CONNECTIVITY broadcast (as seen in android.net.vpn.VpnManager.java source code):

    context.registerReceiver(new BroadcastReceiver()
        {
            public void onReceive(Context context, Intent intent)
            {
                android.util.Log.d("MyApp", "Received VPN broadcast.");
            }
        }, new IntentFilter("vpn.connectivity")); // VpnManager.ACTION_VPN_CONNECTIVITY

So is there a way to detect if a VPN is connected, beside polling the networks interfaces periodically to detect the creation of a new network interface (usually ppp0)?

Best regards, David

like image 975
dbernard Avatar asked May 17 '11 13:05

dbernard


People also ask

Why does my VPN say no Internet connection?

If your VPN software is not working properly, you can do several things: check your network settings, change your server, make sure the right ports are opened, disable the firewall, and reinstall your VPN software. If none of the below methods are working, it's time to contact your VPN provider.

Why does my WiFi stop working when I use VPN?

This can happen if the network has some type of security protocol incompatible with the VPN. It is also possible that the VPN is not configured properly. This can happen if you are using the wrong settings or if the VPN is not set up to work with the specific type of network that you are using.

Why isn't my location changing with a VPN?

Reboot and try again. If the IP address is from another country, but not the one you selected, your VPN may be at fault. Close and restart your client, connect to several servers and verify their location with the iplocation.net (opens in new tab) site. Report any variations to your VPN.


1 Answers

sgs2 and emulator worked with:

    getApplicationContext().registerReceiver(new BroadcastReceiver()
    {
        public void onReceive(Context context, Intent intent)
        {
            logger.Log("VPN broadcast "+context.toString()+": ["+intent.toString()+"]");
        }
    }, new IntentFilter("vpn.connectivity"));
like image 148
Droidee Avatar answered Oct 07 '22 23:10

Droidee