r3dstorm4
r3dstorm4

Reputation: 31

startActivityForResult causes my app to freeze on some devices

I have a device-specific problem. My app starts an intent with startActivityForResult, this works with almost all test devices only on some Android 7 devices, this leads to an APP freeze, where the GUI doesn't react anymore.

The code looks like this:

private void executeAction() {

    if("connect".equals(mStringAction)){

        Intent intent = VpnService.prepare(MainActivity.this);

        if(intent != null){
            startActivityForResult(intent, REQUEST_CONNECT_VPN); // Leads to freeze on some devices like Bacon android 7.1.2 Lineage OS
        }else{
            onActivityResult(REQUEST_CONNECT_VPN, RESULT_OK, null);
        }

REQUEST_CONNECT_VPN is int with value 2

Unfortunately, onActivityResult is never reached. After calling within startActivityForResult, super. startActivityForResult (intent, requestCode); nothing happens after breakpoints in the app. Among all the other devices it jumps back to onActivityResult.

If the intent is null, the APP works properly (except for the skipped code part) and does not freeze.

So my question is why most devices call onActivityResult properly and why it leads to a freeze on several Android 7 devices on the other hand?

Edit:

I found out startActivityForResult caused the app to freeze on some devices, I now added android:launchMode="standard"> to the Manifest. This fixed the freeze for some of the devices which would not work. But apparently there are a view more devices which will just receive RESULT_CANCELED every time.

Upvotes: 0

Views: 312

Answers (0)

Related Questions