Add start logical for onActivity result

This commit is contained in:
Jacques Foucry 2020-05-31 07:32:42 +02:00
parent cff6ad9cfc
commit 410ef5eb45

View file

@ -66,6 +66,7 @@ public class MedicamentListActivity extends AppCompatActivity {
final Boolean DBDEMO = true; final Boolean DBDEMO = true;
final static Random random = new Random(); final static Random random = new Random();
public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff; public final int CUSTOMIZED_REQUEST_CODE = 0x0000ffff;
public final int SAVE_RQUEST_CODE = 0x000000ff;
@Override @Override
public void onStart() { public void onStart() {
@ -286,27 +287,37 @@ public class MedicamentListActivity extends AppCompatActivity {
} }
switch (requestCode) { switch (requestCode) {
case CUSTOMIZED_REQUEST_CODE: { case CUSTOMIZED_REQUEST_CODE: {
Toast.makeText(this, "REQUEST_CODE = " + requestCode, Toast.LENGTH_LONG).show(); Toast.makeText(this, "REQUEST_CODE = " + requestCode + "RESULT_CODE == " + resultCode, Toast.LENGTH_LONG).show();
Log.d(TAG, "requestCode == "+ requestCode);
Log.d(TAG, "resultCode == " + resultCode);
break; break;
} }
default: case SAVE_RQUEST_CODE: {
Toast.makeText(this, "REQUEST_CODE = " + requestCode + "RESULT_CODE == " + resultCode, Toast.LENGTH_LONG).show();
Log.d(TAG, "requestCode == "+ requestCode);
Log.d(TAG, "resultCode == " + resultCode);
break; break;
}
IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data);
if(result.getContents() == null) {
Intent originalIntent = result.getOriginalIntent();
if (originalIntent == null) {
Log.d(TAG, "Cancelled scan");
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else if(originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) {
Log.d(TAG,"Cancelled scan due to missing camera permission");
Toast.makeText(this, "Cancelled due to missing camera permission", Toast.LENGTH_LONG).show();
} }
} else { default {
Log.d(TAG, "Scanned"); Toast.makeText(this, "REQUEST_CODE = " + requestCode + "RESULT_CODE == " + resultCode, Toast.LENGTH_LONG).show();
Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show(); Log.d(TAG, "requestCode == "+ requestCode);
Log.d(TAG, "resultCode == " + resultCode);
IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data);
if(result.getContents() == null) {
Intent originalIntent = result.getOriginalIntent();
if (originalIntent == null) {
Log.d(TAG, "Cancelled scan");
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else if(originalIntent.hasExtra(Intents.Scan.MISSING_CAMERA_PERMISSION)) {
Log.d(TAG,"Cancelled scan due to missing camera permission");
Toast.makeText(this, "Cancelled due to missing camera permission", Toast.LENGTH_LONG).show();
}
} else {
Log.d(TAG, "Scanned");
Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
}
}
} }
} }
@ -533,4 +544,4 @@ public class MedicamentListActivity extends AppCompatActivity {
constructMedsList(); constructMedsList();
} }
} }
*/ */