Answer the question
In order to leave comments, you need to log in
I don't see the activity until the process ends. What to change?
I'm making an application for cleaning the gallery from unnecessary images. There are several rules for pixel-by-pixel image analysis in the analysis - it takes a long time, during which nothing is shown on the screen (dark screen), the application has to be monitored by logs, although I would like to make the image analysis process displayed on the screen of course. At least the number of the image that is currently being analyzed.
That is, after selecting a file through a standard file manager and displaying the final result of image analysis in a folder, a lot of time passes, during which it is not visible what is happening if the application is not logged.
Part of the code with the choice of a file for analysis was taken from the Internet, so I don’t quite understand what needs to be changed so that the activity is displayed during the entire image analysis process.
public class MainActivity extends AppCompatActivity {
private static final int ACTIVITY_CHOOSE_FILE = 3;
TextView sourcePath;
TextView destPath;
TextView imageNumber;
ImageView imageOnProcess;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button chooseFolder = (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);
//МНОГО КОДА ПОПИКСЕЛЬНОГО АНАЛИЗА ИЗОБРАЖЕНИЯ И ПЕРЕМЕЩЕНИЕ В НУЖНУЮ ПАПКУ
}
}
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);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question