Pages

Thursday, December 1, 2011

Update: Version 2.0

Finally released SMS Text Auto Responder version 2.0 on the Android Market!

https://market.android.com/details?id=com.jmarstudios.txtautoresponder.android

I wrote a blog post about it here: http://jmarstudios.com/2011/11/29/update-version-2-0/

Enjoy :)

Saturday, October 15, 2011

Skribblit!

I wrote a new post on http://jmarstudios.com about the new Android application I published to the Android Marketplace... http://jmarstudios.com/2011/10/15/introducing-skribblit/

You can download Skribblit here: https://market.android.com/details?id=com.jmarstudios.skribblit

Enjoy! :)

Friday, October 7, 2011

My New Site! JMaRStudios.com

I have started migrating over to using http://jmarstudios.com I am trying out the WordPress format. So far I'm kinda diggin it ;)

Anyway, that is where I will be posting from now on. Hopefully you will join me :)

Thank you for reading!!!

Wednesday, October 5, 2011

Why Does My ListView Look Different?

It seems to me that the following statement, made by an official Motorola representative, purposefully breaks Android's paradigm of developing an app so that it provides a consistent user experience across all devices.

If you like the gray bottom-of-list background on the Motorola Android 2.3.x devices, and you want your application to blend in with the device rather than look the same across devices, then you’re set. You don’t need to do anything.

The simple fix

But if you (or your client, or users) want the ListView background to display at full screen, or your application to look the same across multiple devices, there’s a simple solution.

How can there be a "simple solution" to wanting what I expect to be the default behavior... looking the same across all devices?

I understand that the manufacturer's are "allowed" to do this. But is that really a good thing? I mean, Motorola actually went out of their way to break the consistent user experience and force it on the developer to do some stupid workaround.

I feel like this fragmentation issue is getting just a tad bit ridiculous...

http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/bc-p/18521

Saturday, October 1, 2011

Using Custom Fonts With Android

I was messing around and figured out how to use custom fonts in your Android application. It's really simple so this will be a quick and dirty how-to...

Custom fonts use the TypeFace class.

First find yourself a nice font... I found and will use this one here called "Cheyenne Hand" at 1001 Free Fonts.

After downloading and unzipping the file, add the ttf font file to your project in the following directory:
assets/fonts/[fontname].ext

Now in your layout file (main.xml in this case) you would create a TextView as you normally would...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
>
    <TextView
        android:id="@+id/textViewDefault"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Default Font Text..."
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:textSize="30sp" />
    <TextView
        android:id="@+id/textViewCustom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Custom Font Text..."
        android:textSize="30sp"
        android:layout_below="@+id/textViewDefault"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="100dp" />
</RelativeLayout>


Now in your activity you create a TypeFace object.
Typeface tf = Typeface.createFromAsset( getAssets(), "fonts/cheyenne_1.ttf" );


Then get the TextView
TextView tv = (TextView)findViewById( R.id.textViewCustom );


Then bind the TypeFace to the TextView
tv.setTypeface( tf );


Now take a look and you will see something like this...



Added source on Google Code: https://code.google.com/p/tutorial-android-custom-font/

Download the apk here:

Tuesday, September 27, 2011

When does assigning variables become more efficient than $_POST?

**NOTE: I wrote this a really long time ago (February 1, 2009) on another blog I used to have and wanted to move some of the articles over here to consolidate them.
To answer the question presented by the article title... All the time!

I was tooling around today and ran across this little gem...

This may not be a big deal, but I'm just kinda curious. If I have a page that submits a form to itself, when is it better to assign each element in $_POST to a variable to use for the rest of the page?

My situation probably doesn't make a difference, but say I have about 10 form fields, and when the page is posted back to itself, i call each of those form fields 2 times (1 for error checking, 1 for SQL insert, or to pre-fill form).

So where does it become more efficient to only call $_POST once and assign those to variables? Do you use the variables if they are needed any more than one time?

Thanks for you thoughts!

IMHO that is a great question!

I believe that the question is best addressed in two parts.
  1. Variable \Reuse
    • This is the one I would like to focus upon today.
  2. Benchmarking

Variable Reuse

Anytime that you plan on using data from the $POST variable (or any request data $_REQUEST, $_GET, et al) in more than one place, it is good practice to contain that data in a variable.

Why?

Let's say you have a name passed into your script via a form that a user submitted. Our POST data could look something like this:

$_POST['firstname'] == 'John'$_POST['lastname'] == 'Smith'

So anytime we want to do something with the first name we simply use the variable

$_POST['firstname']

// Will output John
echo 'First Name: ' . $_POST['firstname'];

That's nice and easy... but if you do plan to use that technique remember, there's a catch!

What if you wanted to use that firstname value for not only outputting to the browser but for other things like inserting into a database and/or retrieving data from a database, etc? Well you could use $_POST['firstname'] over and over again EXCEPT remember that the $_POST variable is a special predefined variable. In reality all the request variables are arrays. Thus when you use 'firstname' you are actually referring to the associative key ('firstname') contained within the array ($_POST) and returning its value ('John'). Well that's all fine and good except what if the key changes to something like, oh let's say 'user_firstname'? This now means that someone (probably you) is going to be tasked with renaming each and every one of the times it was called throughout the script. What about find/replace? That could work but what if it misses just one entry (happened to me today: it was my fault it happened but the fact is, it still happened)? Now you have problems. You now are gifted with a bug that if your lucky you can track down easily and if your not... let's just say that baldness amongst programmers isn't usually caused by inheritance.

Anyway, this potential dilemma is easily solved by containing that data in one central location... a variable.
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];

Now since your data is contained within its own variable, if the key changes you only have to edit one time and it will be seen throughout the rest of the script!

Example:
// This example shows the benefit of using variables to contain request
// data request values
// $_POST['firstname'] == 'John'
// $_POST['lastname'] == 'Smith'

// Since we are containing the data here then this ends up being the
// only place that the post key has to be changed.
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];

function showFullName() {
    echo $firstname . ' ' . $lastname;
}

function insertRecord() {
    $query = "INSERT INTO mydb.ppl VALUES ($firstname, $lastname);
}

Working On Another Site

YAY!!!

I have been working on another site recently for a small business located in Tampa Florida called Avalon Transcription and Document Preperation, LLC.

Take a look at it and let me know what you think :)
Avalon Transcription and Document Preparation, LLC


New Version
Old Version

Thursday, September 22, 2011

Two New Sections (Pages)

I have created two new pages to address user issues with SMS Text Auto Responder. Why does this feel like I need to start thinking about site expansion and evolution... ugh whatever...

Image: Danilo Rizzuti / FreeDigitalPhotos.net
Anyway, I have created a FAQ page where I will answer the most asked questions by users. There is also a page called "My Response to Android Marketplace Comments" On this page I will be directly answering user comments from the Android Marketplace.

The FAQ page is just starting so there is very little content just yet.

The "My Response to Android Marketplace Comments" page has comments and my responses starting from September 1, 2011

Enjoy :)

Saturday, September 17, 2011

Just For Fun...

Just for fun, I thought I would show everyone a preview of the redesign for SMS Text Auto Responder v2...

Let me know what you think so far :)




Monday, September 12, 2011

Newest Update w/ Screen Shots

Version 1.2:
  • Major update to the UI (User Interface)
  • Bug fix in the home screen widget
  • Added AdMob ads...
    • Hopefully these ads will help to offset some of the financial costs that go into maintaining and creating new features for SMS Text Auto Responder.

Thursday, August 11, 2011

YAY!!! Working on a new site...

Just wanted to say that I am happy to announce the release of the blog site for Angela Averett.

She is living the dream... you should check it out.

[http://angelaaverett.com]

Thursday, July 14, 2011

Android: SharedPreferences and Generics Part 1

I love how Android has implemented a super quick and easy method of storing simple primitive key/value data... SharedPreferences

I like to use Android application resources (R class), SharedPreferences and Generics together at the application level to create a real quick and stable system of saving and retrieving simple stored data throughout an entire application.

...extends Application

First I'd like to take a minute and talk about extending the Application class. Usually this is not necessary nor is it a good idea. I believe however, that this is a good way to extend the Application class. It allows easy, consistent access to our SharedPreferences throughout the application and not just in an Activity or Service. It really shines when you create a stand alone class. Using this method you won't have to pass the context around... which can get out of hand real fast!

A little about SharedPreferences...

How do SharedPreferences work and why would I need them?

Android provides many different ways of storing and retrieving data. You could use a premade file, a file on the external storage (microSD) or you could even use the SQLLight database that is provided to you through a content provider.

These are all great and effective methods of storing data but they each come at a cost. Using files creates overhead using the file IObuffer, writing to a database can be painfully slow when writing many times in a short timespan, the list goes on.

So for example, if I have some simple data and it may or may not be written and re-written many times throughout the application's lifecycle, I don't want to have to create DB handlers, calls to content providers and queries and buffered readers and lions and tigers and blah blah blah whatever... just to manage the data.

This is where the SharedPreferences class really shines! Reading and writing data using SharedPreferences is extremely fast, secure (only YOUR application has access to the stored data) and overall easy to use. Simply put SharedPreferences are a quick and easy storage solution that has the ability to store data in key/value pairs.

Here is a simple breakdown of what you can use for the key and the value:

Key: Currently, the key is always a value of the type String.
Value: Currently SharedPreferences only supports storing the following value types:
  • String
  • Integer
  • Float
  • Long
  • Boolean

How to use SharedPreferences

To use the SharedPreference class you must first get a handle to the file.

public class SomeClass {   
   private SharedPreferences mSomePref;
         
   public SomeConstructorOrOnCreate() {
     mSomePref = this.getSharedPreferences( "pref_filename_no_extension", MODE_PRIVATE);
 }
}

Then if you want to put some data, say a string, into that preference file you would do so like this:

private void someMethod() {
  // Do some work...

  // Get a handle to the shared preferences editor
  SharedPreferences.Editor edit = mSomePref.edit();

  // do the work
  edit.putString("myKey", "My value which is the type: String");

  // commit() must ALWAYS be called after doing all the work. If it is not
  // then the changes will NOT be commited!
  edit.commit();
}

Now to retrieve that data we call like this:

  // Get the value of the preference   
  String storedPref = mSomePref.getString("myKey", "Some default value to return if this key doesn't exist"); 

AWESOME!!!
Yeah, all the way until you need to add another preference OR you need to update that one you just set...

private void anotherMethodThatChangesTheStoredPref() {   
  // ...do some work...

  // Need to change the value of my key
  SharedPreferences.Editor edit = mSomePref.edit();
  edit.putString("myKey", "The new value that will overwrite the previously stored value");
  edit.commit(); 
} 

Ah, now I see an encapsulation issue. No problem right? Separate adding the preference into its own method and pass the value in with a parameter.

private setSharedPref(final String key, final String value) {
  SharedPreferences.Editor edit = mSomePref.edit();
  edit.putString(key, value);
  edit.commit();
}

So now we can call it from various methods...

private void methodOne() {
  setSharedPref("myKey", "Some string value");
}

private void methodTwo() {
  // We can update the existing value...
  setSharedPref("myKey", "A new string value");

  // Or we can add a new entry altogether 
  setSharedPref("newKey", "Some string value");
}

This is great! However, we run into an issue when we want to store some other type of data other than strings. What if we want to store a Float or a Boolean? Well we would need to create a method for each type.

private void setStringSharedPref(final String key, final String value) {
  
  SharedPreferences.Editor edit = mSomePref.edit();
  edit.putString(key, value);
  edit.commit();
}
  
private void setFloatSharedPref(final String key, final float value) {  

  SharedPreferences.Editor edit = mSomePref.edit();
  edit.putFloat(key, value);
  edit.commit();
}
  
private void setBooleanSharedPref(final String key, final bool value) {

  SharedPreferences.Editor edit = mSomePref.edit();
  edit.putBoolean(key, value);
  edit.commit();  
}  
  // so on and so forth...  

This is ok but a lot of repetitive code, especially if you want to use your shared preferences in another class because you will have to repeat all this code in that class as well. There has to be a better way, right? Breathe easy people... there is!

Introducing Generics woot woot!!!
Since we may need to insert any one of a number of value types a generic method would be an excellent solution here. A generic method allows you to pass an unknown type using the generic type identifier (usually something like <T>) into the method and it is up to you to determine what was passed and handle it accordingly.

To do this I use a series of if/else statements and check if the class matches the type using getClass().equals(Type.class)

So with that said, our new method would look like:

private final <T> void setSharedPref(final String key, final T value) {
  
  SharedPreferences.Editor = mSomePref.edit();

  if(value.getClass().equals(String.class)) {
    edit.putString(key, (String)value); 
  } else if (value.getClass().equals(Boolean.class)) {
    edit.putBoolean(key, (Boolean)value); 
  } // So on and so forth...

  edit.commit();
}
  
This way allows you to not care what value type you are attempting to pass

So as you can see thus far the SharedPreferences class is a really fast and powerful way of managing simple data and using generics really takes them to the next level!

In the next post I will tie everything together and then demonstrate how to use all of this in a "real world" example.

Sunday, July 10, 2011

Whew...

Ok, finally got all the bugs worked out (hopefully) and I have published the update to the Android Marketplace.

Lots of good stuff in this update too...
  • Fixed not sending issue on some devices!
  • Fixed battery issue on some devices!
  • Major overhaul in how incoming numbers are handled
  • Fixed crash involving screen orientation change while update dialog is showing
  • Fixed crash related to empty outgoing responses
  • Added two new auto response categories and response values
    • Bad Mood
    • Theater
  • A ton of code enhancements and bug fixes!

You can find the latest version here...
SMS Text Auto Responder FREE

and as always if you would like you can always help by purchasing my donate version on the Android Marketplace...
SMS Text Auto Responder DONATE

Monday, July 4, 2011

Whoops! Bug Alert!!!

Okaaaay, so I changed some code regarding how the outgoing response is handled in v0.5.8.3 and I just found a bug with how SMS Text Auto Responder puts the outgoing response in the stock SMS application's database. My mistake...

I should have a fix for this soon...

Tuesday, June 28, 2011

Icons and Icon Decorations in Eclipse

I saw an unfamiliar icon decoration today and wanted to know what it meant. I found this answer on StackOverflow and wanted to link to it in case anyone else wanted to know about Eclipse icons and Eclipse icon decorations in the Package Explorer.

Thanks to Lord Torgamus for the excellent answer on StackOverflow!

His answer (as found on StackOverflow)

This is a fairly comprehensive list from the Eclipse documentation. If anyone knows of another list — maybe with more details, or just the most common icons — feel free to add it. 
Helios: http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-icons.htm 
Galileo: http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/reference/ref-icons.htm?resultof=%22icon%22 
There are also some CDT icons at the bottom of this help page
If you're a Subversion user, the icons you're looking for may actually belong to Subclipse; see this excellent answer for more on those.

Monday, June 27, 2011

New Update and New Donate Version!!!

I'm excited to announce the release of SMS Text Auto Responder FREE v0.5.8 and SMS Text Auto Responder DONATE v1.0!!!

Lots of fun stuff to announce...
  • There are many code enhancements...
  • Added the crash reporting library: ACRA (Application Crash Report for Android)
  • Enable showing the outgoing auto response in the stock SMS application.
    Note: This may not work on all devices. If you experience any issues with this feature go to Settings and disable it then send me an email letting me know what type of device you are using. I will see if there is a fix that I may be able to implement.
  • Added Donate feature to the settings menu
  • Added a Donate version to the Android Marketplace which can be purchased for $1.99USD
  • Updated graphical elements
  • Various major & minor bug fixes
  • Fixed a low memory error on SOME devices
  • Many other nifty things!!!
I have also been re-factoring a lot of the code to bring it in line with the new standards that I have implemented. I am doing this as it will allow me to work on future upgrades more quickly and efficiently.

As always, if you happen to experience any issues please contact me and I will do my best to fix whatever issue you are experiencing with my application. 

You can download the main app here: SMS Text Auto Responder FREE
You can contribute to the cause here: SMS Text Auto Responder DONATE

Enjoy!
Rich

Here are some screenshots of the the final FREE release...









Screenshots from the DONATE release...






Wednesday, June 22, 2011

Simple communication between two different applications

Recently, I faced a problem where I needed two different applications to communicate a simple message between each other. I searched around and found many questions regarding this problem. However, there were a lot of vague answers as well.

I figured I would write this in case someone else faced a similar issue and needed a starting point to work from.

Here was the issue I faced:

  1. The user opens TestAppOne and there is a check to see if TestAppTwo exists.
  2. For this example we will say that TRUE is returned.
  3. Since TestAppTwo exists we open it using startActivityForResult(Intent, int).
  4. When the user is done with TestAppTwo they click a button which sends them back to TestAppOne with the resultCode
  5. Call finish() on TestAppTwo.

 


class TestAppOne extends Activity { 
 //... 
 
 private final void startOtherApp() { 
  //... 
  
  // Here we pass "1" to TestAppTwo 
  this.startActivityForResult(intent, 1); 
  
  //... 
 } 
 
 @Override protected void onActivityResult(int pRequestCode, int pResultCode, Intent pData) { 
  super.onActivityResult(pRequestCode, pResultCode, pData); 
  
  // Check the result code that was sent from the calling activity 
  if( pResultCode == 1 ) { 
   // The result was successfully sent and received 
  } else { 
   // There is something wrong 
  } 
 } 
} 

class TestAppTwo extends Activity { 
 //... 
 
 private void someMethod() { 
  //... 
  
  // Set the result here to be passed back to TestAppOne 
  this.setResult(1); 
  this.finish();
 } 
} 

 

Credits go to:
Android Developer Reference
Let's Share Some Thoughts
Android Forums

Monday, May 30, 2011

Hopefully...

Hopefully I have fixed the Generic Error issue with SMS Text Auto Responder FREE (link)! sorta: I don't know if this will fix the LG Ally issue. If someone with an LG Ally could test it out and let me know if it works or not I would be eternally grateful :)

YAY!!!

The only time I could get it to reproduce the error was when there were SMS messages coming in and the auto responder was trying to send one out at the exact same time. The stock app would attempt to automatically resend the message and retrieve the incoming message at the same time... however what winds up happening is they both keep blocking each other.
Think two people facing each other attempting to go through the same door and each time one moves one way the other inadvertently moves the same direction thus blocking the doorway.

Hopefully it doesn't do this any longer!

Friday, May 13, 2011

AndEngine: Thoughts and Background How-To

I started using AndEngine for Android (link) and I must say, WOW! I'm impressed!

I will say this though...
With all due respect, as amazingly awesome and powerful as this library is it is extremely hindered by its lack of clear and easy to find documentation. It is like pulling teeth trying to figure this thing out! Oh well, if it was easy it wouldn't be fun right!?!??!

Anyway, one of the things I was trying to do was set a static background.
There is probably a better way of doing this but this worked for me.

The way I've done it is as follows...
Landscape mode
I have the camera width and height set at: 854x480
The .jpg image that I use as a background is 854x480

Note: because you need to use a texture that is a power of 2 I had to set the texture area at 1024x512. This didn't seem to affect it.....yet!

@Override
public void onLoadResources() {


    // Create a texture to load our sprite into
    this.mBackgroundTexture = new Texture(1024, 512, TextureOptions.DEFAULT);




    // Create a region to load the image asset into
    this.mBackgroundRegion = TextureRegionFactory.createFromAsset(this.mBackgroundTexturethis, "gfx/YOUR_IMAGE.JPG", 0, 0);


    // Load the texture (with the region that holds the asset) into the engine
    this.mEngine.getTextureManager().loadTexture(this.mBackgroundTexture);
}


@Override
public Scene onLoadScene() {


    // Do scene work...


    // Might not need this but I did it anyway...
    this.setBackground(new ColorBackground(0, 0, 0, 1));


    // Create sprite
this.mBackground = new Sprite(0, 0, this.mBackgroundRegion);

    //Attach the sprite to the scene. I use getFirstChild() so that I can ensure that the background sprite is the "bottom" child
    scene.getFirstChild().attachChild(this.mBackground);


    // Do some other work maybe...


    return scene;
}


I will write up a more thorough tutorial soon!


Hope this helps :)

Blogger Buzz: Blogger is back

Blogger Buzz: Blogger is back: "What a frustrating day. We’re very sorry that you’ve been unable to publish to Blogger for the past 20.5 hours. We’re nearly back to normal..."

Sunday, March 6, 2011

Please Help Me Help You!

When a person leaves a comment on the Android Marketplace I have no way of helping that person. I, as a developer, cannot reply to the comment. I cannot gather more information as to what is happening. All I can do is sit and guess what is happening.

In my last app update I introduced an email button so it would make it easier for a user to contact me directly. Why are they not using it?

So I say... Please Help Me Help You!

I take great pride in my work. I want YOU to have the best, most solid application that I can build! So if you use SMS Text Auto Responder FREE and experience an issue with the application, I implore you to let me know directly.

Monday, February 28, 2011

1000+ DOWNLOADS!!! WOOT!!!

SMS Text Auto Responder FREE hit the 1000+ download mark!!! How exciting WOOHOO!!!

Friday, February 25, 2011

SMS Text Auto Responder FREE... Bring on the widget!!!

Got a lot of bugs cleaned up and code improvements finished!

Hell Yeah!

The only major thing I would like to wrap up is really just a minor annoyance... The status bar notification only updates once when the app AutoResponds.

Now on to creating the homescreen widget for the AutoResponder app... WOOT!!!

Thursday, February 24, 2011

Big update!

I just released a big update to the auto responder!

Initially I made the broadcast receiver using a seperate class and added it through the manifest. While it worked good, doing it that way meant that ANY time an SMS message came in the receiver caught it and started the service. This is a good thing if one wants that sort of functionality. I, however, only want the service running if the user explicity turns it on.

To make sure it behaved properly, I set a boolean flag of sorts when the user started the auto responder. I then checked if that flag was true whenever the service started. If it was false then i had the service shut itself down.

This works good for sure but it never sat well with me.

Now I am using a dynamically registered BroadcastReceiver within my service which is *only* registered when the service is created!
I think this is a much better solution ;)

Sunday, February 20, 2011

idea for my text responder application...

i'm thinking of adding a response log in the options menu so that the user can have a visual record of when SMS Text Auto Responder FREE auto responded to incoming text messages.

Friday, February 18, 2011

SMS Text Auto Responder FREE... Released!

Finally i have released my first Android application on the Android Marketplace!!!
You can check it out here...
App Name: SMS Text Auto Responder FREE
Link: http://market.android.com/details?id=com.jmarstudios.txtautoresponder.android
I am extremely happy :)

Monday, February 14, 2011

SMS Text Auto Responder (txtAutoResponder) for Android

I am currently BETA testing my SMS Auto Responder. Hope to release it soon!!!

Here are some screenshots...