Friday, August 23, 2013

iPoo!!!

Last week, we've introduced iPoo. iPoo is a simple application that helps people find washrooms near their current location if they are in a dire need to go. Currently, we've only made this application available in Canada, while focusing our efforts on Toronto (city where we are currently located).

iPoo has proven to be a difficult launch for us with the main issue of not having any initial washroom data for our app. Initially we do not want users to download iPoo hoping that they will collaborate and input washrooms into our database. This idea wouldn't be wise and prevent the growth of our initial user base. Having initial washroom data, we are hoping that users would like this application and in turn spark a chain reaction where they would contribute by either reporting/rating existing washrooms and if they encounter a washroom not in our database then they would add into our database. In the end we must provide users with at least initial good quality listings of washrooms and in time they would contribute in some way to our application.

Right now, in our Toronto region, we have Starbucks, Second Cup, McDonalds, and Burger King as our main washroom locations. It also includes some non cafe/restaurant locations. This would seem like there would be a lot of washrooms listed in our Toronto region (which is true), but the problem we have with this is that not every single one of these cafe/restaurants have washrooms. So some of the places listed on there do not have washrooms and must be removed, which is the difficult part. Another issue we have in terms of usability is that in the downtown Toronto area, with the underground PATH walkway and financial/office buildings, it is proving difficult to find some of these locations as they can either be location in the PATH walkway, street level, or hidden within one of the office buildings. We would need find a solution to counteract this issue as it will pose problems to our users if they really need to go to the washroom.

Our washroom database also includes library and public park washrooms in Vancouver, library locations in both the city of Calgary and Edmonton.

So for now, with our focus in Toronto, we are hoping that we will further improve our iPoo usability, have more better quality washroom listings, and fix any known bugs with the application. We can only hope right now that people using this application to PLEASE contribute in some way to our application either by reporting, commenting/rating, and adding washrooms.

Download iPoo from Google Play Store!

Thanks!! =)

Friday, August 9, 2013

Android Gallery Intent Example

Android gallery intent is a simple way for users to select images for use in your application. It also makes the  mobile app developer's life easier by not having to implement a graphic user interface for users to use to import an image. There are two different intents that you can implement for users to select an image and import it into your application. You can view my gallery intent example source code in my android-api-example Github project.


Gallery Intent Using Default Gallery Application

If you want to start a gallery application that uses the device's default gallery app, you just need to call the Intent with MediaStore.Image.Media.EXTERNAL_CONTENT_URI and do Activity.startActivityForResult() instead of Activity.startActivity() on that intent. This way, you can retrieve the image path that the user has selected. Then in your overridden Activity.startActivityForResult() it just a matter of retrieving the path where the image is located. Now the tricky part is getting the file path. Tricky because the image file path isn't simply just store in the Intent data variable. Basically, the information returned will in a form of database query, thus a bit of code required to get that file path. Below is the code that I use to get the image file path (for now ignore the else if block of the code). And that is it, with that image file path decode into Bitmap and use it however you like!

Gallery Intent Using with Ability to Choose Gallery Application

Just automatically opening up the default gallery application does not give much choice for your users, hence I will describe how you can give users more flexibility when selecting images on the device. Simply when you create the intent, first specify what type of file you would like to import using MIME type and telling that you want to get some form of content using the constant Intent.ACTION_GET_CONTENT and then finally invoke Activity.startActivityForResult().
Similar to using gallery intent on default gallery app, in Activity.startActivityForResult() get the image file path using the provide code above. I have also mentioned above to ignore the else if block of code. This is where that block of code becomes useful. In the case where the user uses other apps (not the default gallery app), it will return the file path in the Intent data variable, thus it can get easily retrieved.
You can view my Android Camera Intent example HERE.
Relevant files are:
src/com/choiboi/apiexamples/gallery/GalleryMainActivity.java
res/layout/activity_gallery_main.xml

Enjoy!!

Thursday, August 8, 2013

Android Camera Intent Example

Need to incorporate camera into your application? You can follow this instruction HERE provided by Google on creating custom camera app. Or you can do it the easier way which is to start a camera intent. If all you need to do is to capture photos, and do not have the time and resources to create your own custom camera app, then using intent to start the device's camera app is the right way to go. Doing this provides users the ability adjust camera settings provided by the camera app without having you to go through all the trouble creating one from scratch. There are two ways to start a camera intent, which will be described below. In the meantime, if you are eager to look at the source code, it can be view in my android-api-example Github project.

Start Camera Intent without Specified File Path

Basically, all you need to do is create an Intent indicating that you want to capture and image. The value indicating that you would like to capture an image is MediaStore.ACTION_IMAGE_CAPTURE. After when you have created the Intent, we then would want to Activity.startActivityForResult() The reason for using Activity.startActivityForResult() instead of Activity.startActivity() is because we need to retrieve the image that the camera intent returns. You must then override Activity.startActivityForResult() method like in the code below: Since, we have not specified to the camera intent where to save the captured image file, it will return the image as a Bundle within the Intent data. Just as a side note, depending on the device that is being used it will either save a copy of the image file on the device (usually where the camera app saves captured images) or it doesn't.

Start Camera Intent with Specified File Path

In order to provide the Intent with a file path, we must come-up with a file path that we would like it to save it to and the filename. Different device have different starting file paths and to do this safely, I first check there is internal storage available and if there is then I retrieve the root public folder of the device's internal storage. This can be done using Android's Environment class. Then in that public root directory I create a standard Android pictures folder using Environment.DIRECTORY_PICTURES. This code is shown below: Once you have the file path, you just need specify the path into the Intent like this: Then finally in your overridden Activity.startActivityForResult(), since you already know the location of the image, you just need to decode the Bitmap using that file path.


You can view my Android Camera Intent example HERE.
Relevant files are:
src/com/choiboi/apiexamples/camera/CameraMainActivity.java
res/layout/activity_camera_main.xml

Hope this was helpful!!

Saturday, August 3, 2013

Android Toast Example

In this post I will be describing how Android Toasts can be done. Toast implementations are pretty simple and does not require many lines of code. To see my working example application of Toast implementation, you can take a look here android-api-example.




Basic Toast

Creating toasts requires only one line as shown below:
Basically all you need to do is invoke the static method Toast.makeText(), which will create a Toast object. The first argument takes in the current activity's Context object, second argument is the message that you would like to display, and finally the third argument would be the length of time that you would like it to be displayed for. Currently, the third argument will only either accept Toast.LENGTH_SHORT or Toast.LENGTH_LONG and you will not be able specify your own set time. Once the Toast object is created, invoke Toast.show() with that Toast object. If you want to display Toast longer then just replace Toast.LENGTH_SHORT with Toast.LENGTH_LONG and you are done!

Display Toast Even Longer

Currently, I was only able to find one way to display Toasts longer than Toast.LENGTH_LONG. What I did was basically invoke show() on the same Toast object more than once consecutively. This was simply done by using a for loop and looping it as many times as you like. Depending on how many times you loop, it will display it for Toast.LENGTH_LONG times the number of times you loop.
In the above code, I am looping 4 times which results to a Toast message displaying for 4×Toast.LENGTH_LONG amount of time.

Custom Toast Background

If you happen to not like the default background, you create your own custom background and display Toasts messages using that background. To do this, you will first need to create a 9-patch image that you want to use for your Toast background. One tool that you can use to create 9-patch images from an existing image is Nine-patch GeneratorOnce you have placed the 9-patch images to their corresponding folders in your Android project, you need to then create a separate layout for your Toast and set that 9-patch image as background value for your root layout. Like this:
Creating a layout like the above gives you the flexibility on how you want to display your Toast. Once you have created your Toast message layout, next step is just a matter of writing few simple lines of code, shown below.
There is also another way customizing your Toast messages. This is done through Android's XML styling and more information can be found here in this link.

You can view my Android Toast example HERE.
Relevant files are:
src/com/choiboi/apiexamples/toast/ToastMainActivity.java
res/layout/activity_toast.xml
res/layout/activity_toast_custom_toast.xml

Happy Coding!