Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will have quite a few problems with this setup, but this is how you might want to get started:</p> <p>You will have to include an activity in your project which does nothing else than starting the activity you want to get the result from and stores it in a globally accessible storage (e.g. a singleton or a static field).</p> <pre><code>class Pojo { static final ConditionVariable gate = new ConditionVariable(); static int result; int m(Context context) { context.startActivity(new Intent(context, ForwarderActivity.class)); gate.block(); return result; } } class ForwarderActivity extends Activity { private boolean started = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!started) { started = true; startActivityForResult(new Intent("ContactsProvider"), 1); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Pojo.result = resultCode; Pojo.gate.open(); } } </code></pre> <p>There are a couple of problems, though. Like your POJO's method can't be called from the main (UI) thread, because you need to convert an asynchronous call (startActivityForResult()) to a synchronous one (Pojo.m()) and the activity you want to receive info from will be started on the main thread, so you can't block it in Pojo.m()...</p> <p>Anyway, the code does not work, but you can see which way to go if you really have to stick with this setup. But you should really try to come up with some other means of fetching the data, like a content provider.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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