Giter Club home page Giter Club logo

Comments (4)

soulqw avatar soulqw commented on May 31, 2024

你好,这边反馈问题请贴上报错信息,方便定位问题哈

from soulpermission.

soulqw avatar soulqw commented on May 31, 2024

权限使用是没问题的,但是你对相机对操作比如打开相机,开启预览等,应该放在权限请求成功对回调 onAllPermissionOk里面

from soulpermission.

zchrissirhcz avatar zchrissirhcz commented on May 31, 2024

@soulqw 你好,感谢你的快速回复,我按你的建议,把onCreate函数修改为如下:

    @Override
    // 创建Activity时执行的动作
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SoulPermission.getInstance().checkAndRequestPermissions(
                Permissions.build(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE),
                //if you want do noting or no need all the callbacks you may use SimplePermissionsAdapter instead
                new CheckRequestPermissionsListener() {
                    @Override
                    public void onAllPermissionOk(Permission[] allPermissions) {
                        mView = (SurfaceView) findViewById(R.id.surfaceView); //======
                        mHolder = mView.getHolder();                          //======
                        mHolder.addCallback(MainActivity.this);               //======

                        Toast.makeText(MainActivity.this, allPermissions.length + "permissions is ok" +
                                " \n  you can do your operations", Toast.LENGTH_SHORT).show();

                    }

                    @Override
                    public void onPermissionDenied(Permission[] refusedPermissions) {
                        Toast.makeText(MainActivity.this, refusedPermissions[0].toString() +
                                " \n is refused you can not do next things", Toast.LENGTH_SHORT).show();
                    }
                });
    }

我删掉原有安装的apk,重新编译安装apk,现象变为:无论是第一次还是后面,每次打开apk都闪退。

from soulpermission.

soulqw avatar soulqw commented on May 31, 2024

建议观察LogCate 看报错信息,然后你这边应该是在onResume中 权限未获取就调用了Camera.open
,你这边应该在onResume 中添加一个标志位,当权限授予未成功时候直接返回,ok时候将标识位去掉,再重新执行onResume中的逻辑即可

from soulpermission.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.