Do not see activity until the process ends. What to change?

Doing application cleaning gallery from unnecessary images. In the analysis there are a few rules of pixel-by-pixel analysis of the image - it takes a long time, during which the screen shows nothing (black screen), the application has to control the logs, though I would like to make to the process of analyzing the image displayed on the screen of course. At least the image number which is now being analyzed.

That is, after selecting the file via the standard file Manager and display the final result of the analysis of the images in a folder takes a long time, during which you can not see what happens if you do not log the application.

Part of the code with the file selection for analysis are taken from Internet, so I don't quite understand what should be changed to activity displayed during the entire process of image analysis.

public class MainActivity extends AppCompatActivity {

 private static final int ACTIVITY_CHOOSE_FILE = 3;

 TextView sourcePath;
 TextView destPath;
 TextView imageNumber;
 ImageOnProcess ImageView;

@Override
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R. layout.activity_main);

 ChooseFolder Button = (Button) findViewById(R. id.choose_folder);
 sourcePath = (TextView) findViewById(R. id.source_path);
 destPath = (TextView) findViewById(R. id.destination_path);
 imageNumber = (TextView) findViewById(R. id.imagenumber);
 imageOnProcess = (ImageView) findViewById(R. id.imageOnProcess);

 chooseFolder.setOnClickListener(new View.OnClickListener() {
@Override
 public void onClick(View v) {

 Intent chooseFile;
 Intent intent;
 chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("file/*");
 intent = Intent.createChooser(chooseFile, "Choose a file");
 startActivityForResult(intent, ACTIVITY_CHOOSE_FILE);

}
});
}


 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 if (resultCode != RESULT_OK) return;

 if (requestCode == ACTIVITY_CHOOSE_FILE) {
 Uri Uri = data.getData();
 String firstFilePath = getRealPathFromURI(uri);

 //LOT OF CODE PIXEL-BY-PIXEL ANALYSIS OF THE IMAGE AND MOVING IN THE RIGHT FOLDER

}
}

 public String getRealPathFromURI(Uri contentUri) {
 String[] proj = {MediaStore.Images.Media.DATA};
 Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
 if (cursor == null) return null;
 int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
 return cursor.getString(column_index);
}
}
July 9th 19 at 12:58
1 answer
July 9th 19 at 13:00
Below was the response from the interface, you need to code pixel-by-pixel analysis to run in a separate thread in the background. For example, using AsyncTask.

Find more questions by tags Android