Нow to enable and see StrictMode on android in cordova

173 views Asked by At

I modify via hook CordovaActivity.java. I insert the inclusion of a striсt mode there and then in the onTouchEvent I do an endless loop:

package org.apache.cordova;

. . . 
import android.os.StrictMode;

public class CordovaActivity extends Activity {
    . . .

    @Override
    public void onCreate(Bundle savedInstanceState) {
       
       StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .build());
        StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .build();
        StrictMode.setVmPolicy(policy);

        . . .       
    }

    
   @Override
    public boolean onTouchEvent(MotionEvent event) {
        long a = 0;
        while(true) {
            a++;
            if(a == 8000000000L){
                return true;
            }
        }  
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
         int action = ev.getAction();
         Log.d("dispatchTouchEvent WWW", "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");

         super.dispatchTouchEvent(ev);
         long a = 0;
         while(true) {
              a++;
              if(a == 8000000000L){
                   return true;
              }
         }  
    }

    . . . 

I see the logs in the android monitor console.

enter image description here

And when I touch the device I see that a popup appears with a message that the application is not responding. enter image description here

But I do not see the red border around my application although I can see around other applications. I think that I either connected the strict mode or inserted the loop in the wrong place, what exactly is wrong?

0

There are 0 answers