react-native-simple-openvpn icon indicating copy to clipboard operation
react-native-simple-openvpn copied to clipboard

disable vpn on app close

Open tegozen opened this issue 3 years ago • 0 comments

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();
    }
}

tegozen avatar Jan 29 '23 12:01 tegozen