How to add back arrow in AppCompatActivity Android

Hello guys, welcome back it's monday today but I'm not gonna post this day maybe tommorow. Today I don't give article about iOS but Android. Because Android has many users so it's not bad to learn it. Basically it's same logic but just different how to implement the layout and components. Android is using java but you can use kotlin but this article I just show Java code. Because I'm too lazy to convert it hehe.

In this article I wanna talk about activity and navigation when you want to go back previous activity and you need to do it through toolbar. I have found easy way to implement it. It's a few codes line, no need to import icon and libraries.

It's included in Android Studio library. I have tried it like screenshoot above and it works when you extend AppCompatActivity. It will automatically give you a back arrow icon in action bar. No more code needed. It's awesome right, android make it simple.

I haven't tried to override the back button method. But you can try to look it on the internet. It supposed to be ok. 

So this is the code you're looking for :

So this is the code i'm talking about. It's just three line but very helpful. If you have any question about iOS or Android feel free to ask me via comments or email, it's ok. Thanks for visiting my simpe blog.

Popular posts from this blog

How to restart the app with flutter Android and iOS

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android