I have an activity contains WebView and I'm passing URL while opening, Like this:
Intent activity = new Intent(getApplicationContext(),NewActivity.class);
activity.putExtra("URL", url);
startActivity(activity);
When we press back button it closes all previous activities and return to MainActivity so I overrided onBackPressed.
@Override
public void onBackPressed() {
finish();
}
and it still close all previous activities.
Note : It declared in manifest like this:
<activity
android:name=".views.activities.NewActivity"
android:screenOrientation="portrait"/>
What is the wrong with it?
How can i fix this, I just want to open previous activity onBackPressed
and finish current one.
Intent activity = new Intent(CurrentActivity.this, NewActivity.class);
? Try withCurrentActivity.this
instead ofgetApplicationContext()
finish()
on your first activity after starting theNewActivity
?