opensrp / opensrp-client

Android app for Frontline Health Workers (FHWs).
Other
15 stars 32 forks source link

Add error message instead of having app crash every time "+" button is tapped without QR code app installed #172

Open cafootitt opened 8 years ago

cafootitt commented 8 years ago

In both Woman and Child register, the app crashes every time the "+" button is tapped to register a new client, if the user does not have QR code reader app installed. It would be better to return an error or note instructing the user to download a QR code reader from the play store instead of having the app crash.

@maimoonak

maimoonak commented 8 years ago

@cagulas Have you installed QR code reader library on device

It tries to open QR code scanner on new enrollment

cafootitt commented 8 years ago

@maimoonak Yes, the QR code scanner app is installed. This issue is more about adding an error message or a note to the user to install the app. The app shouldn't crash when the button is pressed.

maina commented 8 years ago

@maimoonak I would suggest we wrap the code that starts the "com.google.zxing.client.android.SCAN" intent in a try/catch block to handle ActivityNotFoundException when the QR code scanner app isn't installed. Then in the catch block show an alert dialog asking the user to install QR code scanner app and when they click ok redirect them to google playstore with pname filter as the zxing package: Uri uri = Uri.parse("market://search?q=pname:" + "com.google.zxing.client.android"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); act.startActivity(intent); This way we avoid the crash and let the user download the QR code scanner we expect them to install.

maimoonak commented 8 years ago

Fixed in version 1.4.1 and would be released with pk-vaccinator-2.0.0