Matt Kenefick
Contact Me Experiments Blog Portfolio

Archive for February, 2009

Disabling Wordpress’s “/feed/” link.

Friday, February 27th, 2009

If you want to override the “/feed/” link in Wordpress, there are a few steps to take. This was really annoying for me because I was trying to use it, but it’s not an .htaccess setting or anything like that.

Anyway, what you do is:

  1. Go into “wp-includes/template-loader.php”.
  2. Comment out TWO instances of the following code:
} else if ( is_feed() ) {
do_feed();
return;

Then you’re all set and the “/feed/” link is yours.

What makes up an Android App ?

Sunday, February 8th, 2009

This is taken from the Google documentation but I’m going to attempt to explain it in common developer terms and relationships. Since they are specific, some examples will not be DIRECTLY related, but the idea will help you understand what it’s about a little.

Apps are typically built on a combination of 4 building blocks:
- Activity
- Broadcast Intent Receiver
- Service
- Content Provider

So I’ll jump into the first one which is Activity. This is basically each individual screen of your application. So if we were talking about a webpage… Your homepage is an Activity, your login page is an Activity, your success/error page is an Activity… Basically every screen is an Activity. Of course each screen, just like on a webpage, is built from different components. In the web world, these would be like DIV tags, INPUT components, IMAGES, etc… The page as a whole is an Activity.

Broadcast Intent Receivers (BIR) are similar to, but not identical to, events in Actionscript. In the Android world, a BIR would handle external events of the phone. So if the phone starts ringing, the time changes to midnight, or your lose service.. Your app receives an Event to the BIR. You can think of this as being similar to the Actionscript EventDispatcher. Like the EventDispatcher, you can also broadcast events instead of just listening for them. Some Android code examples would look like… “Context.registerReceiver();” or “Context.sendBroadcast();” .. Looks an awful lot like “addEventListener” and “dispatchEvent” doesn’t it?

A Service is something that will play in the background. The best example (and take THIS iPhone) is playing music. Attaching sound to an Service will allow you to listen to your song as you’re going through different screens in your app. Attaching sound to an Activity will cause your song to stop playing when you switch screens. Services are totally code based, obviously. Try to relate it to the services on your computer. You have services running all the time that manage your network connections, LAMP servers, audio controllers, etc. You don’t SEE them, but they’re handling code continuously in the background. You have control over these as well. You can communicate to see what song is playing, change the song, etc.

The Content Provider is a place to store data. SQLLite or other. It lets you share data with other apps on the phone. There is no specific directory, like “Uploads” or “Files” that every app can access. It must be passed through the Content Provider. This will be covered more later, but for now.. Just think of it as a database that you store/retreive information. Content Provider examples: Contacts, Media, Images, Groups, etc…

These will be covered more later, but hopefully gives a more ‘real-world’ approach to what these terms actually mean.

Actionscript to Android

Sunday, February 8th, 2009

Over the next few weeks.. I’m going to write out some very simple to progressively more advanced Actionscript to Android comparisons. Since it’s all Java based, it should be fairly simple to see the differences and merge your way from AS3 to Android. Instead of explaining a bunch of stuff, I’ll just jump directly into it.

Actionscript 3.0

package com.android.hello {
 
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
 
  public class HelloAndroid extends Activity{
    /** Called when activity is first created */
    public override onCreate( savedInstanceState:Bundle ):void {
      super.onCreate( savedInstanceState );
 
      var tv:TextView = new TextView( this );
      tv.setText("Hello, Android");
      setContentView( tv );
    }
  }
}
Android (Java)

package com.android.hello;
 
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
 
  public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate( Bundle savedInstanceState ) {
       super.onCreate( savedInstanceState );
 
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
    }
}

This is a very simple example that helps show the differences in syntax.

Actionscript 3 Android (Java)
- Enclose package in brackets
- Override after “public”
- Return type (void) AFTER parameters
- Variable type “var varname:Type”
- Do not enclose package
- Override set before method
- Return type (void) BEFORE method name
- Variable type “Type varname”