Reputation: 67
I am calling an app from the other app programatically as below:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(packageString,classApp));
mActivity.startActivity(intent, 2);
I wanted to wait till Intent app execution is completed and closed.
I tried using the startActivityForResult(intent,2). But this dosnt seems to be working as it is not calling the onActivityResult in the actual activity class.I am calling the Intent in the non activity class.
Upvotes: 1
Views: 3020
Reputation: 1006674
I wanted to wait till Intent app execution is completed and closed.
That is not possible. You have no way to know when "app execution is completed and closed", particularly since you are starting up that activity in a new task. For example:
You are welcome to use lifecycle methods, like onStart()
, to determine that you are getting control back, but that does not mean that "app execution is completed and closed".
Upvotes: 1
Reputation: 104
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(packageString,classApp));
setResult(2,intent);
onActivityResult check this.
if(requestCode == 2){
Log.v(TAG ,"Result is Received");
}
please check log in logcat.
Upvotes: 0