Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: View=android.widget.FrameLayout{e3fb200 V.E...C.. ......I. 0,0-210,210} not attached to window manager #30

Open
altaf2892 opened this issue Sep 19, 2018 · 0 comments

Comments

@altaf2892
Copy link

altaf2892 commented Sep 19, 2018

crash in VERSION 7 and WORKING IN 8 OREO

java.lang.IllegalArgumentException: View=android.widget.FrameLayout{e3fb200 V.E...C.. ......I. 0,0-210,210} not attached to window manager at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:473) at android.view.WindowManagerGlobal.updateViewLayout(WindowManagerGlobal.java:368) at android.view.WindowManagerImpl.updateViewLayout(WindowManagerImpl.java:99) at com.premnirmal.Magnet.Magnet$WindowManagerPerformer.onSpringUpdate(Magnet.java:666) at com.facebook.rebound.Spring.advance(Spring.java:441) at com.facebook.rebound.BaseSpringSystem.advance(BaseSpringSystem.java:129) at com.facebook.rebound.BaseSpringSystem.loop(BaseSpringSystem.java:143) at com.facebook.rebound.AndroidSpringLooperFactory$ChoreographerAndroidSpringLooper$1.doFrame(AndroidSpringLooperFactory.java:118) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869) at android.view.Choreographer.doCallbacks(Choreographer.java:683) at android.view.Choreographer.doFrame(Choreographer.java:616) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

below is the function to start a Magnet
`public void startMagnet() {
try {
View mFloatingView = LayoutInflater.from(this).inflate(R.layout.layout_floating_widget, null);

        if (magnet == null) {
            magnet = Magnet.newBuilder(this)
                    .setIconView(mFloatingView)
                    .setIconCallback(this)
                    .setHideFactor(0.2f)
                    .setShouldShowRemoveView(true)
                    .setRemoveIconResId(R.drawable.trash)
                    .setRemoveIconShadow(R.drawable.bottom_shadow)
                    .setShouldStickToWall(true)
                    .setRemoveIconShouldBeResponsive(true)
                    .setInitialPosition(100, 200)
                    .build();
            magnet.show();
            // magnet.setPosition(200, 800);
            mFloatingView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (magnet != null) {
                        magnet.setPosition(500, 800);
                        mFloatingView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                magnet.goToWall();
                            }
                        }, 500);
                    }
                }
            }, 1000);

            mFloatingView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(new Intent(MyFirebaseMessagingService.this, HomeActivity.class));
                }
            });
        }

    } catch (Exception e) {
        Log.e("BUBBLE-catch", e.toString());
    }
}`

below is the function to check permission IN SERVICE
`@RequiresApi(api = Build.VERSION_CODES.M)
boolean checkAndLaunch() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Settings.canDrawOverlays(this)) {
return true;

        }
    }
   /* final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
            Uri.parse("package:" + getPackageName()));
    startActivityForResult(intent, REQUEST_CODE);*/
    return false;
}`

this function is in MainActivity so user will be showing permission window
` @RequiresApi(api = Build.VERSION_CODES.M)
void checkAndLaunch() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, REQUEST_CODE);
}

}}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant