Tuesday, October 29, 2013

Saving to device

UWS and Grubby Boston use a remote file for data, an XML on a website. According to the Android himself, these are the storage methods apps can utilize:
Shared Preferences - Store private primitive data in key-value pairs.
Internal Storage - Store private data on the device memory.
External Storage - Store public data on the shared external storage.
SQLite Databases - Store structured data in a private database.
Network Connection - Store data on the web with your own network server
The next app to come from Butterfruit Labs will store a user profile on the device directly, as in, Internal Storage. External storage saves space on the device, but takes more battery to download and upload. Since the files for our next undisclosed app will be so small, we go internal. From my research, the only read/write permissions are:
 
READ_EXTERNAL_STORAGE
WRITE_EXTERNAL_STORAGE

So its not even necessary to add an extra permission to write internally. To do that, just:

fileoutputstream = new FileOutputStream( root + "/" saveFileName );
 

Saturday, October 26, 2013

Update released

Upper West Sliders version 1.1 has just been released.

Updates:
More deals in the 90's and 100's
New no deals button (hopefully you will never see this)
Food search bug fix
Faster splash screen


 Check it out on Google Play here:
https://play.google.com/store/apps/details?id=labs.butterfruit.upperwestsliders

Button vs ImageButton

All ImageButtons are buttons but not necessarily Buttons, and obviously not all buttons are ImageButtons. Are all TextButtons Buttons? Yes, but it's a trick question, because TextButtons don't exist, since Buttons are text buttons.

When Upper West Sliders couldn't come up with any deals (rare),  some simple text would be displayed informing the user of this sorry state. That's not really helpful, so I wanted to turn that text into a Button, which lets them search again. What's a Button? According to Google, inventor of the Android Button, a Button:

"Represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action.
A typical use of a push-button in an activity would be the following:
 public class MyActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);

         setContentView(R.layout.content_layout_id);

         final Button button = (Button) findViewById(R.id.button_id);
         button.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 // Perform action on click
             }
         });
     }
 }"
 
A button looks pretty basic. Instead of just some text with a rectangular background, why not make the button look like something fun, and delicious, like a hamburger? Yes, Hindus will not like this app, but it will be a big hit in Johnson Market (a Muslim meat market, not a gay bar). To do that we need an ImageButton. Remember that dude, mkyong, I love? Let's ask him for help with an ImageButton:

"
In Android, you can use “android.widget.ImageButton” to display a normal “Button“, with a customized background image.
In this tutorial, we show you how to display a button with a background image named “android_button.png“, when user click on it, display a short message. As simple as that.
1. Add Image to Resources
Put image “android_button.png” into “res/drawable-?dpi” folder. So that Android know where to find your image.
2. Add ImageButton
Open “res/layout/main.xml” file, add a “ImageButton” tag, and defined the background image via “android:src“.
3. Code Code
Here’s the code, add a click listener on image button.
package com.mkyong.android;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
 
public class MyAndroidAppActivity extends Activity {
 
 ImageButton imageButton;
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 
  addListenerOnButton();
 
 }
 
 public void addListenerOnButton() {
 
  imageButton = (ImageButton) findViewById(R.id.imageButton1);
 
  imageButton.setOnClickListener(new OnClickListener() {
 
   @Override
   public void onClick(View arg0) {
 
      Toast.makeText(MyAndroidAppActivity.this,
    "ImageButton is clicked!", Toast.LENGTH_SHORT).show();
 
   }
 
  });
 
 }
 
}

4. Demo

Run the application.
1. Result, a button with a customized background image.
2. Click on the button, a short message is displayed.

Android help shoutout

Lars (see post below) has helped me out a lot with my apps, but I'd like to recognize another super star, 
I won't even hide his Android page in a hyperlink:
http://www.mkyong.com/tutorials/android-tutorial/
Such great tutorials. If you poke around his site, you'll see tutorials for lots of other languages, too. What's his real name? Nobody knows. Actually, I just checked his Google+ page and it says his name is Yong Mook Kim. Here is a picture of this handsome hero:

XML from a remote database

UWS uses an XML format data file, hosted on the internet. To help me with this, I went to the site of Lars Vogel. Thank you please, Lars. First, you have to chose a built in parser

" The Java programming language provides several standard libraries for processing XML files. The SAX and the DOM XML parsers are also available on Android.
The SAX and DOM parsers API is on Android the same as in standard Java. SAX and DOM have their limitations, therefore it is not recommended to use them on Android. Therefore this tutorial does not give an example for the usage of this library.
The Java standard provides also the Stax parser. This parser is not part of the Android platform.
Android provides for XML parsing and writing the XmlPullParser class. This parser is not available in standard Java but is similar to the Stax parser. The parser is hosted at http://www.xmlpull.org/ .
On Android it is recommended to use the XmlPullParser. It has a relatively simple API compared to SAX and DOM and is fast and requires less memory then the DOM API."

With one of these parsers ready, add the permission to open external web pages, then point your parser to the page you want! I made my page very simple, with only XML data. 

Friday, October 25, 2013

Live, planned updates, listview intro

Upper West Sliders is already on the market, but I have updates in the works. UWS relies heavily on ListView. 
"ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list."
Right now, when there are no deals to be shown, you just get a little message saying so. I am going to learn how to make a ListView entry that shows when the next deal is happening. That's a lot more helpful. 
Here is an example of a ListView populated with burgers and maybe a pizza:

Thursday, October 24, 2013

New app published

Nirmal has just uploaded a new APK to the Google Play App Store, it will go live in a few hours! And, it is free, as in mangoes.

Free vs Paid Apps

To maximize both customer satisfaction and profit, should apps be free or paid? Users seem to maintain a tolerance for ads in free apps, which generates some money. One of Butterfruit Lab's current apps generates about the same amount of money with the ad-supported free app and the paid version with more content and no ads. 

According to Tech Crunch, paid apps are dead. The rate of free apps appearing in app stores is increasing. If these apps offer satisfactory alternatives to paid apps, we've got a positive feedback loop. Here's a graph from Flurry Analytics showing the recent decrease in the popularity of paid apps:


What's interesting is that the $5.99 apps seemed to disappear completely in 2012, but reappear in 2013. Maybe paid apps are losing ground, but people are willing to pay a good about for high quality ones. What does everyone think about apps with paid "Pro" or "Ad-free" versions? Or, what about in-app purchases?

Wednesday, October 23, 2013

XML Parsing

A major help with my XML parsing was Abbas Suterwala. Thank you, man. XML parsing was tricky for a programming newb (of which Butterfruit Labs has many).

Here is his introduction on parsing, which he said better than I can:

"We are in an age where, typically, an application cannot work in total isolation and does not have all the data it needs to do its work. It generally has to communicate to some other application–maybe over the internet–and read or send some data to it.
However, the applications with which your app communicates might not be developed using the same technology as yours. For smooth data exchanges between your app and some other application you might be exchanging data in an open format like Extensible Markup language or XML.
An XML document is a human readable text document that contains some starting and ending tags with attributes and data in those tags. Most of the languages and platforms have support for parsing and creating XML documents in them. Android also provides us APIs so that we can work and process XML documents in our app with ease and flexibility. In this article, we are going to see how you can work effectively with XML documents in your Android app."

When you are done, you can make a simple XML page like this (also Abbas' example)

<?xml version="1.0" encoding="UTF-8"?>
<products>
 <product>     
  <productname>Jeans</productname>
  <productcolor>red</productcolor>
  <productquantity>5</productquantity>
 </product>
 <product>     
  <productname>Tshirt</productname>
  <productcolor>blue</productcolor>
  <productquantity>3</productquantity>
 </product>
 <product>     
  <productname>shorts</productname>
  <productcolor>green</productcolor>
  <productquantity>4</productquantity>
 </product>
</products>

And the Parser can pull the info from it, in a form you can manipulate in your app.

Check out his XML Parsing page to learn just like I did!


Android programming resources

What's a good resource for advancing android app programming?
Usually I head to Youtube and have to filter through a dozen videos before I can find someone I understand.

Empty space turns black in Blogspot?

When I post .png's and .gif's to this Blogspot, the empty background goes black. It is quite troubling to Nirmal. Is that the template, or is it a Blogspot quirk?

Get ready for UWS

Now that Nirmal lives in NYC, it's time for a new Grubby Boston. I could have called it Grubby NY, but that's redundant. The entirety of NYC is also overwhelming, so Nirmal has begun with the Upper West Side, a neighborhood that is pretty boring most of the time. Indeed, a better, more up-to-date, and easier to use happy hour app would be doing the Upper West Side a social service. Introducing: Upper West Sliders. More details to follow...


n.b. Logo is still being rehashed.

Monday, October 21, 2013

Rupee woes

Check this out:

"Since January this year, the rupee has weakened 10.61%"

It's a great article from livemint.com about the declining value of the rupee. I remember when 44 rupees bought a dollar. It's a good thing Nirmal operates in USD.

"The rupee ended at 61.5213 per dollar, down 0.42% from its previous close of 61.2650. The partially convertible currency opened at 61.345 a dollar and touched a high and a low of 61.34 and 61.58, respectively
Since January this year, the rupee has weakened 10.61% and has lost the second most after Japanese yen among Asian currencies during that period."
 
For reference, a delicious butterfruit smoothie will run you around 20 rupees. I guess that's still a lot of butterfruit for your buck.

Ahhh, my first ever app, R.I.P. BossManWalla

Unfortunately BossManWalla has been retired due to Android 4+ incompatibilities.
"Specially app for Indians, everyone know Desi is about honking all of the time. But interesting fact about it is now you can enjoy honk as well. BossManWala is rickshaw horn at your finger for making lots of noise for example in MG Road. Scooty and auto and lorry and even donkey make honk at you well now return sound with handheld technology device. You yourself be Boss Man Walla!"

Shoutout to favourite Happy Hour bars in Boston

Red Hat, in Beacon Hill
Pour House, in Back Bay
Grendel's Den, in Harvard Square

What is Grubby Boston?

I should take a minute to introduce my favorite Android project, Grubby Boston. In the Commonwealth of Massachusetts, as many students know, happy hours are illegal. I'm sure there are some very legitimate puritanical reasoning involving sobriety and decency to back up this law. Some weirdos actually like this nonsense, because: 

1. Drinks are cheaper all the time (what other cityies have bars selling $1 drafts all day and night?)
2. Food gets really really cheap just as most people get out of work and are hungry.

Grubby Boston plays on the latter of those two advantages. Just enter the day, time, and neighborhood you want some food specials, and it spits out all sorts of deals. Crazy deals. Some examples are ten-cent wings, dollar burgers, and half-priced menus. Of course there are your typical one buck oysters, happening at a bazillion different seafood restaurants every day.

Like many apps, Grubby Boston offers a free and paid version. The free version just limits the amount of deals shown at any time. The paid version, which costs a whopping $0.99, doesn't hold anything back. At 5pm on some days, there are almost 30 deals. The free version doesn't have any ads, and probably never will. 

So far, I've seen a ton of happy hour apps, but most stay clear of Boston because of the statutory lack of alcohol specials. Grubby Boston fills this niche. Hopefully, there are a lot more students like me - hungry, cheap, and armed with technology.

Grubby Boston Screenshots

  




Grubby Boston Promo!

Here's the Grubby Boston logo/promo I designed. It's an outline of the Boston skyline, from a picture I took across the Charles River. I kept it dual-tone, that's Android green and white. What's that in the sky? It's a giant burger with a B on it, like those Red Sox hats all the Boston Bros enjoy wearing. Maybe this graphic doesn't really convey "happy hour food specials" as much as I'd like, but, I think its pretty hip all the same.

Sunday, October 20, 2013

Trouble with Ads

Butterfruit Labs has been advertising on BodyBuild Pro for a while now - but with the new Adsense, that might all be over. Google won't let Butterfruit upgrade to a new Admob account without an Adsense account, even though it's a MOBILE DEVELOPMENT company. This Catch-22 is causing a lot of trouble with the development team at Ranka Park.