Note that there are some explanatory texts on larger screens.

plurals
  1. PORoboguice (1.1 and 1.2 Snapshot) injecting the wrong context in onActivityResult
    text
    copied!<p>onActivityResult() is a standard Android function that is called after a child Activity closes. However, it doesn't seem to close all the way.</p> <p>After my child activity finishes, onActivityResult() is called in the parent. At this point, my action is to inject a context (through a provider, non-assisted) in a new class the parent is creating, using the parcelable information that the child has just given back to me for an @Assisted parameter in that new class. </p> <p>However, despite finish() being called on the child, the context that is injected is not the parent--it is the child! This kills the program.</p> <p>How do I get around this?</p> <p>Here's some code that gives you an idea of what I'm doing.</p> <p>In the parent:</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_NEW_EXERCISE) { if (resultCode == RESULT_OK) { EntityExercise exercise = (EntityExercise)data.getExtras().get("exercise"); addNewRoutineExerciseDetail(exercise); //Toast.makeText(this, exercise.getName(), Toast.LENGTH_LONG).show(); } } } public RoutineExerciseDetail addNewRoutineExerciseDetail(EntityExercise exercise) { RoutineExerciseDetail detail = detailFactory.create(exercise); detail.setOnClickRelativeLayoutListener(mEditParamsOnClickListener); return detail; } </code></pre> <p>In the child:</p> <pre><code>View.OnClickListener mListenerReturnExercise = new View.OnClickListener() { @Override public void onClick(View v) { Intent resultIntent = new Intent(); resultIntent.putExtra("exercise", (EntityExercise)v.getTag()); //Assuming it's the tag setResult(Activity.RESULT_OK, resultIntent); finish(); } }; </code></pre> <p>RoutineExerciseDetail's constructor's parameters:</p> <pre><code>@Inject public RoutineExerciseDetail(ActivityBaseRoboOrm&lt;DatabaseHelper&gt; context, List&lt;RoutineExerciseDetail&gt; list, @AddEditExercise TableLayout layout, @Assisted EntityExercise exercise) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload