Commit 7f0c849f authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Fix NPE on plugin in onActivityResult

parent 125dd14b
......@@ -19,14 +19,11 @@ import androidx.core.content.FileProvider;
public class PhotoActivity extends AppCompatActivity {
private Uri photoURI;
private PhotoPlugin plugin;
@Override
protected void onStart() {
super.onStart();
BackgroundService.RunWithPlugin(this, getIntent().getStringExtra("deviceId"), PhotoPlugin.class, plugin -> this.plugin = plugin);
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
......@@ -61,12 +58,13 @@ public class PhotoActivity extends AppCompatActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == -1) {
plugin.sendPhoto(photoURI);
} else {
plugin.sendCancel();
}
BackgroundService.RunWithPlugin(this, getIntent().getStringExtra("deviceId"), PhotoPlugin.class, plugin -> {
if (resultCode == -1) {
plugin.sendPhoto(photoURI);
} else {
plugin.sendCancel();
}
});
finish();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment