I have the main activity that is an activity and another class (which is a simple Java class), we call it "SimpleClass "Say". Now I want to start with that class command startActivityForResult.
Now though I can pass that class (simple class), only reference to the main activity, the problem is that, you StartActivityForResult (...);
So the only way to use 'StartActivityForResult' for SimpleClass; In the form of simple activity, reference of main activity is to be given as an ordinary class:
Within the MainActivity class, I create an example of SimpleClass in this way:
SimpleClass SimpleClass = new SimpleClass (main activity.);
Now how simple a class it looks:
public class SimpleClass {activity myMainActivity; Public CircleClass (Activity Main Activity) {Super (); this.myMainActivity = MainActivity;} .... Public Zero Certain Methods (...) {myMainActivity.startActivityForRe Sult (...); }}
Now its work, but there is not a proper way to do this? I am afraid that some memory leaks may occur in the future.
Thank you Ray.
I do not know whether this is a good practice, but It should be compiled, and the actual activity holding the result reference should be distributed. casting < / P>
if (mContext instance of activity) {(activity) mContext) .startActivityForResult (.. ..); } Else {Log.e ("should be an example of mContext activity."); }
Comments
Post a Comment