react-native-simple-openvpn
react-native-simple-openvpn copied to clipboard
disable vpn on app close
I noticed that there is no such possibility for android, although it is for ios.
I did it myself like this project/android/app/src/main/java/com/yourapp/MainActivity.java
import android.content.ComponentName;
import android.content.Intent;
public class MainActivity extends ReactActivity {
@Override
protected void onDestroy(){
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName(this, "de.blinkt.openvpn.core.OpenVPNService"));
intent.setAction("de.blinkt.openvpn.DISCONNECT_VPN");
startService(intent);
} catch(Exception err){
}
super.onDestroy();
}
}