karanvs / hiddenshot

hiddenshot is a simple library to take a screenshot programmatically on demand. Screenshot is saved in the picture folder on the device. You may also share a screenshot programmatically.
Apache License 2.0
17 stars 8 forks source link

Not working #1

Open Omurbek opened 5 years ago

Omurbek commented 5 years ago

Hello sir, ive tried your library, but after clicking to the button i cant share image. It shows error

sini180 commented 5 years ago

Hello sir, ive tried your library, but after clicking to the button i cant share image. It shows error

Hi Omurbek. Add the below your onCreate and it should resolve the problem.

StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());

So it should look similar to below....

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
        StrictMode.setVmPolicy(builder.build());

        findViewById(R.id.take).setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View view) {

                HiddenShot.getInstance().buildShotAndShare(MainActivity.this);
                Toast.makeText(MainActivity.this, "taken", Toast.LENGTH_SHORT).show();
            }
        });