Reputation: 3564
I have a file CartActivity.kt from which I make an external API call. If the API call is successful it launches an activity called CurrentOrders.
val currentOrdersIntent = Intent(this@CartActivity, CurrentOrdersActivity::class.java)
currentOrdersIntent.putExtra("orderListObj",orderListObj)
currentOrdersIntent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
Toast.makeText(this@CartActivity,"${response.body()?.message}",Toast.LENGTH_SHORT).show()
startActivity(currentOrdersIntent)
finish()
My CurrentActivity code contains a recyclerview and a button that makes a call to external API.
My problem is that once I reach currentOrders from cartactivity I have to press back button 4-5 times before it reaches the activity that started the cartactivity.
Ideally what I want if Activity A starts cartactivity which in turn starts currentactivity, so after I press back from current activity it should route me to activity A.
Here is the link to CartActivity. Link to CurrentActivity.
This is the link for Complete-project.
Upvotes: 2
Views: 277
Reputation: 11018
What I am getting is your CurrentOrders is getting started multiple times. you can do something like this to make it a single instance. but you need to check why it's getting started multiple times. mean while you can
just try to add this to your affected activity which one is getting duplicated in manifest.
<activity ..
android:launchMode= "singleInstance" />
Upvotes: 1