I am working on to capture image function through Intent call.
I have been successful in implementing startActivityforResult from non-Activity class. I am getting activity Context there.
Now, I want to receive onActivityResult in same java class. As I know it's compulsory to have Activity class to receive this method.
Will it be possible?
I tried to call with Java Proxy , InvocationHandler link but I didn't get success.
code:
public class NovusAPI {
private Context mContext;
private NativeActivity nativeactivity;
static final int REQUEST_IMAGE_CAPTURE = 1;
/**
* Constructor. Save reference to NativeActivity object
**/
NovusAPI(NativeActivity ref) {
nativeactivity = ref;
Log.d(TAG, "NovusAPI constructor called");
}
public void captureImage(){
Log.d(TAG, "Image Capture Call");
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "novus");
values.put(MediaStore.Images.Media.DESCRIPTION, "novus camera capture");
// capture image camera
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
nativeactivity.startActivityForResult(intent,REQUEST_IMAGE_CAPTURE);
}
EDIT:
PreferenceManager Class:
public interface OnActivityResultListener {
/**
* See Activity's onActivityResult.
*
* @return Whether the request code was handled (in which case
* subsequent listeners will not be called.
*/
boolean onActivityResult(int requestCode, int resultCode, Intent data);
}
OnActivityResultListener is interface for Android Preference class. So,I do to work on this to InvocationHanlder link.