I have an existing application. Now I want to add some extra functionality into it. The extra functionality require some library. If i use the library in my app, the application size increases. So I want to make this extra functionality in a separate app and then integrate the new app to my existing app ( If i have some update for the existing app, then I have to download the whole app, which I don't want). I don't want both in one apk. Both should be standalone. From First application let say A, I want to call an activity in the new application B. I used intent.setComponent() and the activity of application B is called from A but I cannot get the result from Application B back in the first application.
Application A
public void onClickBtnToApplicationB(View v) {
try {
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
final ComponentName cn = new ComponentName("pakacagename","package.class");
intent.setComponent(cn);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, REQUEST_CODE);
} catch (ActivityNotFoundException e) {
//handle Exception
}
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case REQUEST_CODE:
handleResult(resultCode, intent);
break;
}
}
public void handleResult(int resultCode, Intent intentResult) {
switch (resultCode) {
case RESULT_OK:
String Result = intentResult.getStringExtra("RESULT");
// I need Results from Application B here..
break;
case RESULT_CANCELED:
break;
}
}
Application B: In application B, class 1 starts another activity for Result 2.class and get the results. After the results are received they are send back to the first application in handle result method'a putextras. So I need to get result in Application A's handleresult method which I didn't get.
Intent s = new Intent(1.this,2.class);
startActivityForResult(s, REQUEST_CODE_B);
protected void onActivityResult(int requestCode, int resultCode, Intent intentResult) {
switch(requestCode){
case REQUEST_CODE_B:
handleResult(resultCode, intentResult);
}
}
public void handleResult(int resultCode, Intent intentResult) {
switch (resultCode) {
case RESULT_OK:
String scanResult = intentResult.getStringExtra("RESULT");
Intent newintent = new Intent();
newintent.putExtra("RESULT", scanResult);
setResult(Activity.RESULT_OK, newintent);
finish();
break;
case RESULT_CANCELED:
break;
}