I have a problem with resume/pause application. Now, suppose that we have an activity that I override onBackPressed() method and redefine for this method is as follows :
@Override
public void onBackPressed() {
moveTaskToBack(true);
}
So, it ran in background without any problem. So, To resume my application, I declare following code in onResume() override method :
@Override
protected void onResume() {
Intent resume = new Intent(this, MainActivity.class);
if ((resume.getFlags() & Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) != 0) {
resume.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Logger.e(M_tag, "Resume Activity");
startActivity(resume);
return;
}
super.onResume();
}
After minimizing the process, I can successfully resume the activity, but the problem that i faced with it, is when I long press on a link in Internet Browser and share link with my application, it resumes the activity but don’t run the condition
if (getIntent().getAction().equals(Intent.ACTION_SEND))
that i defined in the onCreate() override method, like below :
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (getIntent().getAction.equals(Intent.ACTION_SEND))
Log.e("App", "In action send mode");
}
I’ve tested Intent.ACTION_SEND action while no process in background, and it successfully runs the condition, but now, how can I force my applicatin to run ACTION_SEND intent ?
Thanks in advance.
If you are not getting OnCreate for a new intent you will be getting OnNewIntent.
Handle the intent again in this method.