asked    Oscar     2018-10-22       android       86 view        1 Answer

[SOLVED] How to crop the screenshot please?

Hello i have a code to take a screenshot then share it and its work very well But i want to crop this screenshot from the both top and bottom . I hope to help me because i am new in coding . This is the code that i use it :

share.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Bitmap bitmap = takeScreenshot();

    public Bitmap takeScreenshot() {
        View rootView = findViewById(;
        return rootView.getDrawingCache();

    private void saveBitmap(Bitmap bitmap) {
        imagePath = new File(Environment.getExternalStorageDirectory() + "/screenshot.png"); ////File imagePath
        FileOutputStream fos;
        try {
            fos = new FileOutputStream(imagePath);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
        } catch (FileNotFoundException e) {
            Log.e("GREC", e.getMessage(), e);
        } catch (IOException e) {
            Log.e("GREC", e.getMessage(), e);

    private void shareIt() {
        Uri myUri = Uri.fromFile(imagePath);
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.putExtra(Intent.EXTRA_STREAM, myUri);
        startActivity(Intent.createChooser(sharingIntent, "Share via"));



  1 Answer  

        answered    Ellis     2018-10-22      

If you want to use a library, you can implement this library. And follow this code

From ArthurHub/Android-Image-Cropper


<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat"/> <!-- optional (needed if default theme has no action bar) -->

To start CropImageActivity

// start picker to get image for cropping and then use the image in cropping 

// start cropping activity for pre-acquired image saved on the device

// for fragment (DO NOT use `getActivity()`)
         .start(getContext(), this);

Override onActivityResult

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
           Uri resultUri = result.getUri();
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
          Exception error = result.getError();

Your Answer

 2018-10-22         Jim

WebClient How to flush part of received data?

I want to implement partial flushing of the received content. For example, I have the handler:return client .post() .body(BodyInserters.fromDataBuffers( request.body(BodyExtractors.toDataBuffers()))) .exchange() .....How to force flushing when some amount of databuffers is received? First, a word of warning about this:by default (i.e. if you don't flush manually), Netty will buffer bytes and flush them from time to time, whenever the channel is ready and the flushing strategy thinks it's convenient. This is optimized for performance.if you wish to flu...
 spring-boot                     1 answers                     62 view
 2018-10-22         Steward

Function now executing properly after subscribe

I am having a Mono object, On which I have subscribed for doOnsuccess, In this method again I am saving the data in DB(CouchBase Using ReactiveCouchbaseRepository). after that, I am not getting any logs for Line1 and line2.But this is working fine if I do not save this object, means I am getting logs for line 2. Mono<User> result = context.getPayload(User.class); result.doOnSuccess( user -> { System.out.println("############I got the user"+user);>{ System.out.println("user saved"); // ...
 reactive-programming                     1 answers                     61 view
 2018-10-22         Adam

WebClient doesn't read response until request write is completed.

I'm trying to implement streaming proxy.I faced with the issue with WebClient from spring reactive.Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side?Stack:reactor-netty 0.7.8.RELEASEspring-boot 2.0.4.RELEASEDesc:I want to proxy a long stream to external service and then forward stream of responses to the requester.Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked).External service processes every chunk and sends to the response result.Expected behaviour:WebClient should read every received part of response ...
 spring                     1 answers                     68 view