# Hard back button on \<ion-select\> does not close pop up (Android)

**URL:** <https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295>\
**Category:** ionic-v3\
**Created:** [January 25, 2017, 7:36am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295 "2017-01-25T07:36:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron13](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ron13/32/106367_2.png) [@Ron13](https://forum.ionicframework.com/u/Ron13)\
**Post date:** [January 25, 2017, 7:36am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/1 "2017-01-25T07:36:51Z")

</div>

When you press the hard back button on ion-select, the pop up does not close, instead it changes the background page. The same issue is seen even for DatePicker. when the pop ups are triggered from html, there is no way we can close it, unless we press “cancel”/“ok” button, or if we touch around the pop up screen. Since android users like to use the hard back button, it is of utmost importance to fix this issue.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [January 25, 2017, 8:04pm UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/2 "2017-01-25T20:04:22Z")

</div>

Can you open an issue for this?  
It should close in my opinion, but we may have missed this.

---

<div class="post-metadata">

**Author:** ![PrathimaRao](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@PrathimaRao](https://forum.ionicframework.com/u/PrathimaRao)\
**Post date:** [February 20, 2017, 11:49am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/3 "2017-02-20T11:49:14Z")

</div>

Hi,

Did you find a solution to this?  
I am stuck at similar situation. Any help would be appreciated!

Thanks!

---

<div class="post-metadata">

**Author:** ![Ron13](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ron13/32/106367_2.png) [@Ron13](https://forum.ionicframework.com/u/Ron13)\
**Post date:** [February 20, 2017, 12:38pm UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/4 "2017-02-20T12:38:32Z")

</div>

No, its still not fixed.

> <https://github.com/ionic-team/ionic/issues/10168>

---

<div class="post-metadata">

**Author:** ![PrathimaRao](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@PrathimaRao](https://forum.ionicframework.com/u/PrathimaRao)\
**Post date:** [April 21, 2017, 5:22am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/5 "2017-04-21T05:22:37Z")

</div>

Thanks for the information

---

<div class="post-metadata">

**Author:** ![krunal2194](https://avatars.discourse-cdn.com/v4/letter/k/d9b06d/32.png) [@krunal2194](https://forum.ionicframework.com/u/krunal2194)\
**Post date:** [November 8, 2017, 6:32am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/6 "2017-11-08T06:32:31Z")

</div>

Team ionic please provide solution for actionsheet dismiss on hardware back button.

---

<div class="post-metadata">

**Author:** ![jagationic](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jagationic](https://forum.ionicframework.com/u/jagationic)\
**Post date:** [May 1, 2018, 6:40am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/7 "2018-05-01T06:40:04Z")

</div>

Find the solution:

public initializeBackButtonCustomHandler(): void {  
this.unregisterBackButtonAction = this.platform.registerBackButtonAction(() =\> {  
this.customHandleBackButton();  
}, 10);  
}  
private customHandleBackButton(): void {  
const overlayView = this.app.\_overlayPortal.\_views[0];  
if (overlayView && overlayView.dismiss) {  
overlayView.dismiss();// it will close the modals, alerts  
} else {  
this.navCtrl.setRoot(‘HomePage’);//do what do you want to do  
}  
}

---

<div class="post-metadata">

**Author:** ![vasanthb](https://avatars.discourse-cdn.com/v4/letter/v/4da419/32.png) [@vasanthb](https://forum.ionicframework.com/u/vasanthb)\
**Post date:** [June 5, 2018, 6:03am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/8 "2018-06-05T06:03:18Z")

</div>

Thank u man, it worked for me.

---

<div class="post-metadata">

**Author:** ![miki021](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@miki021](https://forum.ionicframework.com/u/miki021)\
**Post date:** [September 4, 2018, 5:08pm UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/9 "2018-09-04T17:08:39Z")

</div>

Before you implement @jagationic’s logic, make sure to import:  
import { IonicApp } from ‘ionic-angular’;

and add this to the constructor:  
constructor(private app: IonicApp){}

---

<div class="post-metadata">

**Author:** ![princeraiz](https://avatars.discourse-cdn.com/v4/letter/p/9dc877/32.png) [@princeraiz](https://forum.ionicframework.com/u/princeraiz)\
**Post date:** [October 29, 2018, 7:11am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/10 "2018-10-29T07:11:06Z")

</div>

Tnx buddy its great solution . i stuck in situation that what is app and how it import . So from other example i add it .  
import {IonicApp } from ‘ionic-angular’;

also add  
private ionicApp: IonicApp

take it  
onst overlayView = this.ionicApp.\_overlayPortal.\_views[0];

---

<div class="post-metadata">

**Author:** ![roxannelighting](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@roxannelighting](https://forum.ionicframework.com/u/roxannelighting)\
**Post date:** [July 28, 2019, 7:01am UTC](https://forum.ionicframework.com/t/hard-back-button-on-ion-select-does-not-close-pop-up-android/77295/11 "2019-07-28T07:01:11Z")

</div>

Thanks, It worked for me.
