use startActivityForResult from non-activity
<p>I have MainActivity  which is an Activity and other class(which is a simple java class), we`ll call it "SimpleClass".
now i want to run from that class the command startActivityForResult.</p>

<p>now i though that i could pass that class(SimpleClass), only MainActivity's context, problem is that, u cant run context.startActivityForResult(...);</p>

<p>so the only way making SimpleClass to use 'startActivityForResult; is to pass the reference of MainActivity as an Activity variable to the SimpleClass 
something like that:</p>

<p>inside the MainActivity class i create the instance of SimpleClass this way:</p>

<pre><code>SimpleClass simpleClass=new SimpleClass(MainActivity.this);
</code></pre>

<hr>

<p>now this is how SimpleClass looks like:</p>

<pre><code>public Class SimpleClass {

Activity myMainActivity;

   public SimpleClass(Activity mainActivity) {
       super();
       this.myMainActivity=mainActivity;    
   }
....


    public void someMethod(...) {
        myMainActivity.startActivityForResult(...);
    }

}
</code></pre>

<p>now its working, but isnt a proper way of doing this? I`am afraid i could have some memory leaks in the future.</p>

<p>thanks.
ray.</p>
