Archive for the ‘Linux’ Category.

Android Virtual Device (AVD) extremely slow

So I started to look at writing an Android app. I took a class on Android and wrote a prototype Android App in fall of 2011. Well, I have a need to write an Android App again.

I am a C# developer and while I am comfortable with Java, I prefer C# so I am going to use MonoDroid.

I installed everything very easily using the MonoDroid installer. However, when I went to launch an Android Virtual Device (AVD) it seemed to start but even after leaving it over night, it didn’t finish booting.

So I did some research and the recommendation was to install the Hardware Accelerated Execution Manager.

So I had to:
1. Open the Android SDK Manager and install the Intel x86 Emulator Accelorator (HAXM).

2. Run the installer I found here:
C:\Users\jbarneck\AppData\Local\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager\IntelHaxm.exe

After that, opening an AVD was plenty fast.

Non-technical reasons for why Linux has a larger open source market share than FreeBSD

It is not always about who is better. Often an equal or better candidate loses for reasons that should not apply. This is true for many areas (politics for example) where what matters is overlooked by our humanity. So whether one operating system is technically better than the other is not the only factor for choosing it. Linux is the most used open source operating system and has a larger market share than FreeBSD (OS X not included). This article takes a look at some other reasons one might choose Linux over FreeBSD.

Note: This article also is not taking into account OS X, which while it has some foundations is BSD, is not open source, and this article is to discuss open source market share. Due to OS X, FreeBSD could make the claim that they have a larger market share than Linux.

Reason #1 Advertising

The bottom line to advertising is that Linux has it in quantities and FreeBSD doesn’t.

Advertising

For FreeBSD, there is very little, if any, advertising. I have never seen any ad on any media type for FreeBSD.

Linux has multiple enterprise size companies, Red Hat, SUSE (previously Novel), IBM, and others that are advertising it and using it. Linux is advertised by these companies quite heavily.

Buzz

There are a few user’s groups here and there and that is about it. FreeBSD has no little buzz marketing.

Linux has a lot of buzz. There is no questioning the buzz that was created by Ubuntu that still exists. Thanks to distros like Ubuntu, Linux has an extreme amount of buzz.

What is being done?

Over the past couple of years, iXSystems has provided an increase in advertising. Also the new BSD Magazine is another form of advertising that is beneficial.

Reason #2 – Brand name and Logo

A brand name has the ability to make or break an organization. A logo has this same ability. Why? Because they are the embodiment of the company. They provide the first impressions (don’t tell me you haven’t heard that saying about first impressions) and often the only impression.

And how it sounds is extremely important.

Think about it. Some people want to sound cool when they say the operating system they run.

  • “I run Linux!”
  • “I run FreeBSD!”
I have heard people say it many times: Linux as a word just sounds cooler than FreeBSD. Well, lets actually look at from a more scientific point of view than “just sounds cooler”.  Let look at reasons

The linguistics of a brand name

Linguistic experts have studied brand names and there are many “best practices” for a brand name, and FreeBSD follows none of them. Because of this, FreeBSD is not a good brand name. It is not even average. In fact, if you were to make a list of below average brand name, FreeBSD would reside near the bottom of the bad list, and here is why.

The goal of a looking at a brand name from a linguistics point of view is to find ways to make the brand easy to say, descriptive, and memorable . A brand name is poetry and all the linguistic elements that benefit or distract from poetry can benefit or distract from a brand name. Here are ten linguistic suggestions for having a good brand name.

  1. Use alliteration in your brand name.
  2. Use equal or more harmonious consonants than cacophonous sounds. Some consonants make sounds that are “in-between” such as F. A letter such as X has two sounds, K and S.
  3. Syllables. Two or three syllables is ideal. One doable too. Four is possible if other items in this list are good. Five syllables and above your pretty much a bad brand name.
  4. Use the correct “foot“. Use disyllables such as pyrrhic, iamb,  trochee, but avoid spondee; Use trisyllables such as anaepest, credic, dactyl but avoid molossus etc…
  5. Avoid using acronyms.
  6. Vowels should rhyme or match.
  7. Avoid contrasting vowel sounds, such as a long vowel followed immediately by a short vowel.
  8. The place of articulation of each consonant and transitions between them should be easy.
  9. Use a word that can become a noun or verb.
  10. Know definitions of roots, prefixes, and postfixes and use ones that apply to your business.

So lets compare FreeBSD brand to the Linux brand.

Winner FreeBSD Linux Explanation
1 Tie n/a n/a Neither alliterated.
2 Linux Good Bad Linux has three consonants, but one is X which has two consonant sounds K and S. Sot it has, three harmonious, one cacophanous which is a 3-1 ratio.
FreeBSD has five consonants, two cacophonous, two harmonious, one in-between, which is a 2-2-1 ratio.
3 Linux Good Bad Linux is idea having two syllables.
FreeBSD is four syllables and nothing to save it.
4 Linux Good Bad Linux is a single pyrrhic foot.
FreeBSD has two feet and they are same foot, spondee, which is the one you should avoid.
5 Linux Good Bad Linux avoided acronyms, FreeBSD, has a three-letter acronym.
6 Linux Good Average Linux is two short vowels.
FreeBSD has four vowels, three long Es and one short E.
7 Linux n/a Bad Linux has no vowels next to each other.
FreeBSD has a conflict of a long E followed by a short E between the B and S letters.
8 Linux Good Average Linux has the L and N and S sounds all made by very the same mouth parts and positions, well separated by vowels.
FreeBSD has sounds made by various different places and parts in the mouth less easy transistions.
9 Linux Average Bad Linux can be a noun, and I have heard linuxed used before.
FreeBSD is barely passable as a noun and can in no way be verabalized.
10 Tie n/a n/a Linux has no syllables with any dictionary meaning.
FreeBSD has the word “free” which is too general to provide any meaning. The acronyms detracts from the mean further.

If we rated these on a scale of 0 to 5, with bad being 0, average being 3, and Good being 5, here is how the points come out.

  • FreeBSD = 2 points. Two item were N/A, so that is 2 out of 40 possible points or 5% of the possible Good points a brand could have.
  • Linux = 35 points. Three items were N/A, so that is 33 out of 35 possible points or 94% of the possible Good points a brand could have.

As you can see, from a linguistics point of view, FreeBSD is a terrible brand name. If FreeBSD were an enterprise trying to stay alive, the first order of business would be to change the brand name. Also, this analysis proves the obvious, that most of the bad branding stems from the acronym, BSD.

Derivative brand names

Derivatives of Linux, such as Red Hat, and Ubuntu have average or above average brand name as well.  Red Hat is two simple words, though they unfortunately have no meaning for an open source operating system, but as brand name these words are simple and easy to say. Simple and easy.  Ubuntu has meaning, three syllables, matching vowels, though it isn’t exactly easy to say with 2 cacophonous to only one harmonious consonant.  Both of these

Unfortunately, the FreeBSD derivatives don’t get better. The main problem is that more than half of them feel the need to continue to use the BSD acronym in their brand. There reasoning is to show their ties to BSD, but the result is very bad brand names. For example, PC-BSD somehow took a step backward by extending to five syllables, still all accented, and adding one more cacophonous sound. There is no fixing the PC-BSD brand. The only option is a new brand. However, DragonFly BSD can easily be fixed by simply dropping the “BSD” acronym as it is not needed. Alone DragonFly is a good brand. Brands that have dropped the BSD acronym such as m0n0wall or pfSense are adequate brands, not good, not bad. OpenBSD is as bad as PC-BSD with the added negative that the word “open” actually contradicts the security goals of the platform.

As derivative brand names go, Linux derivatives or distros are far ahead of FreeBSD derivatives in brand name quality.

The art of a logo

The logo is every bit as important as the brand name. Lets look at the FreeBSD logo, and the Red Hat logo and compare them.

Here are some logo tips that seemed to be common themes from dozens of sites about tips for making a good logo.

  1. Keep it simple.
  2. Make it memorable.
  3. Make sure colors coordinate.
  4. Make sure the logo has a black and white version.
  5. Color psychology. Avoid having the logo be mostly one color that may be negative.
  6. Don’t stray far from a simply decorated version of the company name.
  7. Make the logo an image that is pertinent to the brand.
  8. Avoid offensive images, even if only offensive to a small portion of the population.

One might argue that the Tux, the penguin, and Beastie, the devil or demon, are both part logo and part mascot so we will look at those, first.

 

Winner Linux FreeBSD Explanation
1 Tie Bad Bad Neither the penguin or Beastie are simple logos.
2 Tie Average Average Both are memorable
3 Tie Good Good Both have colors that coordinate fine.
4 Linux Good Average The penguin translates well to black and white.
Beastie is displayed as an outline.
5 Tie Average Average Tux is black, white, and yellow. Nothing great.
Beastie is red mostly.
6 Tie bad Bad Both stray from the brand name, probably
because they are more mascots than logos.
7 Tie bad Bad Neither is pertinent to the brand.
8 Linux Good Bad The penguin is nice and cute.
Beastie is a devil and controversially offensive. The reference to daemons and forks is lost on most people.

Ok, so neither mascot makes a good logo, but Tux does have a small edge over Beastie. Now lets look at the logos. I am going to use the Red Hat logo versus the FreeBSD logo, as Linux doesn’t exactly have its own logo.

Red Hat Logo FreeBSD logo

Winner Linux FreeBSD Explanation
1 Linux Average Bad Red Hat is two colors and is a complex drawing.
FreeBSD is a 3d sphere, it is more than two colors, red and black, as it has many different shades of red.
2 Tie Average Average Both are equally memorable
3 Tie Good Good Both are very well color cordinated.
4 Tie Bad Bad The color red makes both logos. Neither look as good in black and white only.
5 Tie Average Average Both have red and black. Not much difference.
6 Tie Average Average Both are an image to the left of the brand name.
7 Linux Good Bad Red Hat has a logo of a guy in a Red Hat, not pertanent to Linux but very pretinent to the brand.
FreeBSD has sphere with horns, and the relationship to a daemon is a stretch at best.
8 Linux Good Bad The Red Hat logo is a simple image, nothing offensive.
The devil horns comes with tons of religious history and is offensive to certain individuals, even toned down as a sphere with horns.

Using the same point system, 0, 3, 5 for Bad, Average, Good…

Linux gets 27 out of 40 possible points, or 67.5%.

FreeBSD gets 14 of a  40 points, or 35%.

After analyzing this, the FreeBSD logo isn’t as good overall as the Red Hat logo using the measurement above. However, I wouldn’t say the Red Hat logo is great either. I do think that just from a “looks and coolness” despite the rating system, the new BSD logo looks better.

What is being done?

FreeBSD recently updated the logo to the one you see above. There are no plans to improve the name, logo, or brand further that I know of.

Reason #3 – Licensing

Business and enterprise drive use. In my experience, business leaders equate open source software with the GPL license. I have heard so many companies say that they have banned open source software. However, every business leader I have educated in the different open sources licenses change the ban to allow BSD and similar licensed, citing that they didn’t understand the different licenses or the business and enterprise friendliness of the BSD and similar licenses.

Both the FreeBSD license and the GPL are great licenses. However, they have a slight different focus.  FreeBSD is a license designed to share code freely. GPL is also a license to share the code freely with the added enforcement that any code that uses GPL code is also GPL.

I have another post to discuss Differences between the BSD/FreeBSD Copyrights and the GNU Public License (GPL).

  • If you distribute binaries built using BSD Licensed source, there are only two things you shouldn’t do (you wouldn’t do either anyway).
  • If you distribute binaries built using GPL source, you have to pay attention. 1) your code may also be required to use the GPL license and 2) there are actions you must perform, such as provide access to the source and your source that uses the GPL source.

Businesses and enterprises often don’t understand that there are alternate licenses beyond GPL. Sometimes they actually prefer to buy commercial software just to avoid “open source”. We need to share how enterprise friendly the BSD license is with IT managers and business decisions makers.

I have seen this from personal experience. At a previous company, they mistakenly used GPL software and other software thinking it was free, forgetting that they actually have to perform actions in order to use this software. It cost them a lot of money when they were found out. The sad part is there was alternate  software available that was BSD Licensed, so they wasted money because neither the developers nor the business leader knew better. I knew better and they were quite shocked when I gave them a simple solution: Just use this alternate software as it is BSD Licensed. They did and it saved them a lot of money.

Even though I put licensing as the third reason, after thinking about it, this comes back to Reason #1 – Advertising again, because the main problem is that the GPL seems to be advertised more and many business leader are unaware of other open source licenses.

What is being done?

I think nothing is being done. I am not sure if there is any effort to advertise the benefits of the FreeBSD’s permissive licensing over other more restrictive licenses.

Reason #4 – A law suit early on

This was before my time, but I always hear that around the time Linux and BSD were released, BSD was sued and so people shied away from BSD because the threat of a law suit. This occurred well before I cared and if you want to read more about it, check out the wikipedia artcle.

http://en.wikipedia.org/wiki/USL_v._BSDi

I can’t prove that BSD was slowed by this, or that Linux wouldn’t have the same advantage in market share over BSD had this occurred. But every time I see a question about why FreeBSD is not more popular someone brings this up.

However, when Linux was sued by SCO, it didn’t really affect the market, so I am not sure if this was really valid or not. It is a historical possibility at best.

Reason #5 – Company backing

We know that in the early days of Linux there were multiple business who backed Linux. Then Red Hat and SUSE went enterprise. Ubuntu has Canonical.

For FreeBSD, Apple took it into their product but not as open source, and they didn’t really advertise the fact that they were partially BSD. iXSystems and some hosting companies are about all that FreeBSD has when it comes to an business.

What is being done?

Well, FreeBSD is continuing to get backing from Apple. I have heard rumors that Apple is one of the primary sponsors of Clang and LLVM (tools to replace gcc as a compiler) that uses a permissive license.

iXSystems kept FreeNAS a FreeBSD product by sponsoring it and has sponsored many booths at open source conferences.

I have heard of Yahoo being a strong backer of FreeBSD, though I am not sure of any recent examples.  But it is clear that FreeBSD needs more business backing if it plans to compete in the open source market with Linux.

10 Reasons why Linux as a Desktop is rarely found in an Enterprise

Application and Development

  1. Commercial apps. Like it or not the best apps, from MS Office, Adobe Creative Suite, and thousands more, exist only for Windows and most cross-platform apps just mean Windows and Mac.
  2. Internal custom apps are almost all written for Windows only. And when they are web apps they often use SharePoint with IE only features.
  3. Lack of enterprise product support for any operating system but Windows.
  4. Rapid desktop application development on Windows with Visual Studio is orders of magnitude faster than on Linux with its best IDE, which is arguably Eclipse.

Infrastructure

  1. Most existing desktop operating systems are already Windows.
  2. Desktop Management solutions that Enterprise IT departments use to manage their workstations only manage Windows or if they manage multiple operating systems, they manage Windows the best.
  3. Existing infrastructure (such as phone systems, etc…) integrate with Windows but not with Linux.

Employees

  1. Existing Full-time employees (FTE) in IT are skilled in Windows and employee replacement or training costs are high.
  2. The cost of Linux FTE in IT is higher than Windows FTE in IT.

Advertising

  1. Most companies start small and grow to be an enterprise. When most companies are started, they are started by people who have never heard of or seen Linux.

Will this change in the future?

Maybe. Change is possible but it takes a lot of time and I don’t mean just years, I mean decades. And during these decades every OS vendor is going to fight to gain a monopoly in the enterprise desktop world.

If it does happen, the changes are for the following reasons.

  1. To better support  mobile devices such as iOS and Android (which is sort of Linux)
    1. As more applications become browser apps or cloud apps that work in any browser.
  2. Cross platform development tools, such as Mono and Java and AIR are really improving.

For those who are pro-Linux because it is open source and you believe knowledge belongs to the world, the enterprise doesn’t care. This argument is completely irrelevant from an enterprise perspective. I care, though, if that makes you feel any better (though I am a person not an Enterprise).

What if a Startup uses an Open Source Operating System

Well, look at the 10 items above and you will see you can eliminate 2, 5, 7, 8, and 10. Half the reasons are eliminated by starting with an Open Source OS.  However, on the other hand, half the reasons still exist.

LANDesk Support Tools – Android Edition (Demo)

This is my first real project written for Android. Yes, I wrote it in C# using Mono for Android.

Android and Xml Serialization with Simple

Xml serialization is almost becoming a standard requirement for a language these days and so as I have been taking an Android class and I couldn’t find an Xml Serialization library as part of Android by default, I set out in search of one.

I came across a java XML Serialization project called Simple.

So here is a quick entry-level example of how to use Simple in an Android development project.

Note: This walk-thru assumes you are using Eclipse.

Step 1 – Create a new Android Project

  1. Go to File | New Project and select Android.
  2. Provide a Project Name.
  3. Select the minimum build target.
  4. Provide a Package name.
  5. Click Finish.

Step 2 – Download Simple

  1. Go to the Simple download page: http://simple.sourceforge.net/download.php
  2. Extract the zip file.

Step 3 – Add the Simple library to your project

  1. Create a folder called libs in your project.
  2. Copy the jar file called simple-xml-2.6.2.jar to the libs directory you just created.Note: Be aware your version may be newer than 2.6.2.
  3. In Eclipse, right-click on simple-xml-2.6.2.jar (if it doesn’t show up refresh) and choose Build Path | Add to Build Path.

Step 4 – Create an Serializeable object

  1. Right-click on your package and choose New | Class.
  2. Provide a class name and click ok.
  3. The following is an example Person class:Person.java
    package org.jaredbarneck.cs6890;
    
    import org.simpleframework.xml.Element;
    import org.simpleframework.xml.Root;
    
    @Root
    public class Person
    {
    
    	public Person()
    	{
    	}
    
    	public Person(String inFirstName, String inLastName)
    	{
    		SetFirstname(inFirstName);
    		SetLastname(inLastName);
    	}
    
    	@Element
    	private String FirstName;
    
    	public String GetFirstName()
    	{
    		return FirstName;
    	}
    
    	public void SetFirstname(String inFirstName)
    	{
    		FirstName = inFirstName;
    	}
    
    	@Element
    	private String LastName;
    
    	public String GetLastName()
    	{
    		return LastName;
    	}
    
    	public void SetLastname(String inLastName)
    	{
    		LastName = inLastName;
    	}
    
    	@Override
    	public boolean equals(Object inObject)
    	{
    		if (inObject instanceof Person)
    		{
    			Person inPerson = (Person)inObject;
    			return this.FirstName.equalsIgnoreCase(inPerson.FirstName)
    				&& this.LastName.equalsIgnoreCase(inPerson.LastName);
    		}
    		return false;
    	}
    }
    

Step 5 – Serialize and Deserialize in your main Activity

  1. Add the following code to your main Activity:Note: Code should be clear and is commented.PersonActivity.java
    package org.jaredbarneck.cs6890;
    
    import java.io.File;
    
    import org.simpleframework.xml.Serializer;
    import org.simpleframework.xml.core.Persister;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class PersonActivity extends Activity
    {
    	public void onCreate(Bundle savedInstanceState)
    	{
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.main);
    
    		// Create a Person object
    		Person person1 = new Person("John", "Johnson");
    
    		// Create a file to save to and make sure to use the path provided from
    		// getFilesDir().getPath().
    		File xmlFile = new File(getFilesDir().getPath() + "/Person.xml");
    
    		// Serialize the Person
    
    		try
    		{
    			Serializer serializer = new Persister();
    			serializer.write(person1, xmlFile);
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    
    		// Create a second person object
    		Person person2 = null;
    
    		// Deserialize the Person
    		if (xmlFile.exists())
    		{
    			try
    			{
    				Serializer serializer = new Persister();
    				person2 = serializer.read(Person.class, xmlFile);
    			}
    			catch (Exception e)
    			{
    				e.printStackTrace();
    			}
    		}
    
    		boolean b = person1.equals(person2);
    	}
    }
    

Go ahead and try this in your Android emulator and step through it with a debugger.

You have now successfully implemented Xml Serialization in Java on Android using Simple.

How to make a Makefile?

Most software compiled on BLU (BSD/Linux/Unix) operating systems is done using make.

The simplest Makefile

The simplest Makefile compiles one single executable. Think of your simplest “Hello, World!” project.

HelloWorld.cpp

#include <iostream>
using namespace std;
int main() {
  cout << "Hello, World!";
  return(0);
}

Of course, for one file you don’t need a Makefile. You could simply run this command that will compile hw.cpp

g++ -o HelloWorld HelloWorld.cpp

So even though a Makefile seems useless for a single file, here is how you would do it.

all:
	g++ -o HelloWorld HelloWorld.cpp

Notice that you have a label and the same compile command one line below the label.

Important! The syntax requires the second line to start with a tab.

Adding objects to your Makefile

Lets assume instead of one file, you have the three file HelloWord.

  • Main.cpp
  • HelloWorld.h
  • HelloWord.cpp

Main.cpp

#include <iostream>
#include "HelloWorld.h"

using namespace std;

int main()
{
  HelloWorld hw = HelloWorld();
  cout << hw.Text << endl;
}

HelloWorld.h

#include <iostream>

using namespace std;

class HelloWorld
{
public:
  HelloWorld();
  ~HelloWorld();

  string Text;
};

HelloWorld.cpp

#include "HelloWorld.h"

HelloWorld::HelloWorld()
{
  Text = string("Hello, World!");
}

HelloWorld::~HelloWorld()
{
}

This simple project can also easily be compiled without a Makefile using this command line.

g++ -o HelloWorld Main.cpp HelloWorld.cpp

However, even with only three files you can start to see how it is much easier to type make than the lengthening command above.

Makefile

all:
	g++ -o HelloWorld Main.cpp HelloWorld.cpp

This is not perfect however, as this compiles both files every time make is run. If changes are made only to Main.cpp there is no reason to recompile HelloWorld.cpp. We can accomplish this by compiling HelloWorld.cpp to a HelloWorld.o module.

all: HelloWorld.o
	g++ -o HelloWorld Main.cpp HelloWorld.o

Similarly if you make changes to HelloWorld.h or HelloWorld.cpp, why do you need to recompile Main.cpp? So you can make it a module too.

all: Main.o HelloWorld.o
	g++ -o HelloWorld Main.o HelloWorld.o

Now only the libraries that have been modified will be recompiled when you run make. This can save significant build time when the project size increases.

Using variables in your Makefile

Mistakes are annoying.  Having to type the same thing in multiple places often leads to mistakes and typos. If you look at the above, there is duplication that is unnecessary.

Makefile with duplication

all: Main.o HelloWorld.o
	g++ -o HelloWorld Main.o HelloWorld.o

Makefile using a variable to avoid duplication

objs = Main.o HelloWorld.o
all: ${objs}
	g++ -o HelloWorld ${objs}

We can even add more variables which may not seem useful now, but are useful later.

CXX = g++
CXXFLAGS =
objs = Main.o HelloWorld.o
Outfile = HelloWorld

all: ${objs}
	${CXX} ${CXXFLAGS} -o ${Outfile} ${objs}

Think about it. Right now you only have one build command, but someday on a huge project you may have dozens and possibly hundreds. Could you imaging changing the CXXFLAGS everywhere? We don’t even have one listed yet, but of course, with the variable you only have to change it once in one place and it will work everywhere you used it.

Adding make clean to your Makefile

It is very common to want to delete all build files and build again. This is often done with the make clean command. But to get make clean to work you have to create a section or label in the make file called clean.

Because we already have variables, it is easy to configure the Makefile to support make clean.

Makefile with clean

CC = g++
CXXFLAGS = -W
objs = Main.o HelloWorld.o
Outfile = HelloWorld

all: ${objs}
	${CC} ${CXXFLAGS} -o ${Outfile} ${objs}

clean:
	rm ${objs} ${outfile}

So simple, we just use rm to delete the files we created, which are all in variables so we had a nice clean short command.

Adding debugging to your make file

There are two schools of thought for debugging.

  • All builds should be release builds unless you run make debug.
  • All builds should be debug builds unless you run make release.

I am not going to tell you which school of thought you should have.  What matters is that you can configure the Makefile to perform how you want it to.

This make file will always build without debugging (release) unless yous specify make debug.

CXX = g++
CXXFlags = -W
objs = Main.o HelloWorld.o
Outfile = HelloWorld

all: objects build

objects: ${objs}

debug: clean
CXXFLAGS += -g
LDFLAGS += -g

debug: objects build

build:
	${CXX} ${CXXFLAGS} -o ${Outfile} ${objs}

clean:
	rm -f ${objs} ${Outfile}

Notice we set LDFLAGS but we never actually call it. It is a special variable that is called automatically by the linker when creating the objects. Yes it must be capitalized.

How to create an Android menu?

Ok, so adding a menu that pops up from the bottom when the menu button is clicked is very common and quite easy to do.

Note: This assumes you have the Android SDK, Emulator, and Eclipse all working already.

Step 1 – Create your Android project

  1. In Eclipse, select File | New Project | Android | Android Project.
  2. Give your project a Name.
    I named this project “HelloAll”.
  3. Select the Build Target (the minimum version of Android).
    I selected Android 2.2.
  4. Enter a Package name.
    Package name is like a namespace, it can be anything you want, but you should actually choose a name as carefully as you choose and the name of an object.  I named the package this: org.rhyous.
  5. Click Finish.

Your project is now created.

Step 2 – Add an XML file for the menu

  1. Expand the res directory in your project.
  2. Right-click on the layout folder and choose New | Other.
  3. Choose XML | XML file and click Next.
  4. Name the file.
    I named my file menu.xml.
  5. Click Finish.
  6. Add the following text into your menu:
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
        id="@+id/menu_item_1" android:title="@string/menu_1"/>
        id="@+id/menu_item_2" android:title="@string/menu_2"/>
        <item android:id="@+id/menu_item_3" android:title="@string/menu_3"/>
    </menu>
    

Step 3 – Add the strings for the menu items

  1. Expand the res\values directory in your project.
  2. Open the strings.xml.
  3. Add strings for each menu item.
    Make sure you use the same id strings you used in the menu.xml for the title of each menu item.
    Your strings.xml should now look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="hello">Hello World, HelloAllActivity!</string>
        <string name="app_name">HelloAll</string>
        <string name="menu_1">Menu 1</string>
        <string name="menu_2">Menu 2</string>
        <string name="menu_3">Menu 3</string>
    </resources>
    

You now have a menu and strings for each menu item.

Step 4 – Overload onCreateOptionsMenu

  1. Open your Activity.
    Mine is src\org.rhyous\HelloAllActivity.java.
    It should look like this:

    package org.rhyous;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class HelloAllActivity extends Activity {
    	/** Called when the activity is first created. */
    	@Override
    	public void onCreate(Bundle inSavedInstanceState) {
    		super.onCreate(inSavedInstanceState);
    		setContentView(R.layout.main);
    	}
    }
    
  2. Add code to override onCreateOptionsMenu and add code to inflate the menu.
    	@Override
    	public boolean onCreateOptionsMenu(Menu inMenu) {
    		super.onCreateOptionsMenu(inMenu);
    		getMenuInflater().inflate(R.layout.menu, inMenu);
    		return true;
    	}
    

You can now build your application and test that the menu pops up. However, the menu doesn’t do anything yet.

Step 5 – Overload onCreateOptionsMenu

  1. Add code to override onOptionsItemSelected and add code to inflate the menu.
  2. Use a switch statement with the inItem.getItemId() function to perform the appropriate action for each menu item.
    	@Override
    	public boolean onOptionsItemSelected(MenuItem inItem) {
    		switch (inItem.getItemId()) {
    		case R.id.menu_item_1:
    			// Do something here
    			return true;
    		case R.id.menu_item_2:
    			// Do something here
    			return true;
    		default:
    			// Should never get here
    			return false;
    		}
    

Based on the item clicked, the appropriate code will run.

Hope you enjoyed this simple Android development example.

HTC Sensation Battery Life meets the low expectations I’ve heard

Update: A system update just came out and it claims longer battery life, so I will have to test again…

My HTC Sensation looks like it will probably have a battery life of 1.5 days for me before it hit 9% battery. I have heard that even though it boasts That is less than I hoped. I was hoping for two days, so I would only have to plug it in every other evening. Maybe 9% would last me till tonight, but I doubt it.

A few notes on this 1.5 days.

  • I used my HTC Sensation for browsing the web for a good 45 minutes straight in the evening, so maybe I used more battery life than normal last night.
  • I was on the phone no more than 10 minutes
  • I made sure to keep all services, GPS, Wi-fi, etc., off during most of this time as I am fine turning them on when I use them.

So I also may have used less battery than some who must have these services enabled all the time.

I hoped that since I turned off these services, I would get much more than two days, even with good hour of use at some point during that span. But alas, the HTC Sensation Battery Life meets the low expectations I’ve heard from others. I have already bought a car charger (well, actually I bought an iGo tip to go with my iGo Car Charger) and I will certainly buy a an extra charger to have at my desk at work as well.

Transfering contacts to my HTC Sensation 4G

So as I mentioned previously, I just got a new T-Mobile HTC Sensation 4G and of course I had to transfer my files.

UPDATE: I just realized you can skip transferring to a PC and connect your old phone to your new phone via Bluetooth and just transfer the files straight from your old phone to your new phone, eliminating the computer as the middle man.

Retrieving contacts from a deactivated phone to your Computer or to your HTC Sensation 4G

First I had to get them off my Motorola RAZR V3m, which I did using this guys steps:

Tutorial: Move your Verizon contacts from your deactivated RAZR to your iPhone

Though there was no copyright listed, I want to give the author credit, especially since I am including a copy of these steps here (though I am modifying them) in case his site ever goes dark.

You can use these steps to transfer your contacts to a computer or to transfer them directly to your HTC Sensation 4G.

Step 1 – Enable Bluetooth

  1. Turn your Bluetooth on, and make sure it’s discoverable.  Do this for each device.
  2. On either device, scan for or add a new Bluetooth device.
  3. Connect/Pair the two devices.
  4. Enter the pin in both devices to pair them.

Step 2 – Send the Contacts

  1. On your old RAZR V3m, select Contacts on your phone.
  2. Select Options.
  3. Scroll all the way to the bottom of that ridiculous list.  See the one that says, “Send Name Card.”  Select it.
  4. Only one card will have been selected (likely the first on your contacts list).  Hit the “Add” softkey option, and select “Add All.”
  5. Press “Send.”  It’s going to ask you where to send them.  You’re going to tell it to send to the computer to which you just paired your phone.
  6. On your computer or HTC, notice automatic activity.  You will need to confirm that it’s okay with you for the transfer to happen.

You should now have a bunch of .vcf files.

On Windows 7, they are here: C:\Users\UserName\Documents\Bluetooth Exchange Folder

Hopefully, you will find similar steps for your phone if it is not a RAZR V3m

Transferring Contacts to your HTC Sensation 4G

If you transferred the contacts to your HTC Sensation 4g, skip directly to Step 4.

Step 1 – Turn on Bluetooth

  1. Click on the bottom left icon to go to All Apps.
  2. Scroll down and select Settings.
  3. Click on Wireless & Networks.
  4. Turn on Bluetooth by clicking it (make sure the check box is green).

Step 2 – Connect the HTC Sensation 4G to your computer via Bluetooth

  1. On your computer (I used Windows 7) click Add device from your Bluetooth options.
  2. Windows searches for you device. Click it when it is found.
  3. Enter the number that pops up on the screen into your HTC Sensation 4G.

You are now connected via Bluetooth from your laptop and on your laptop the Bluetooth device control window should appear.

Step 3 – Send your .vcf files to the HTC Sensation 4G

  1. On your laptop, in the Bluetooth device control window, click the link under file transfer: “Send files to your (HTC Sensation 4G) phone”.
  2. Click Browse Files.
  3. Add all the .vcf files that you previously transferred to this folder: C:\Users\UserName\Documents\Bluetooth Exchange Folder
  4. Click Send.
  5. On your HTC Sensation 4G, you will get prompted to allow the transfer. Allow it.

The .vcf files should now be on the SD card in your HTC Sensation 4G.

Step 4 – Import all the .vcf files to your HTC Sensation 4G

  1. On your HTC Sensation 4G, click Contacts.
  2. Click the second icon below the screen (has one longer horizontal line above three shorter horizontal lines).
  3. Select Import/Export.
  4. Select Import from SD Card.
  5. Choose the account to import to, I used Google.
  6. Choose to import All vCard files.
  7. Click Ok.

You should now have imported all your contacts.

Hope this helps you.

I just got an Android Phone at a discount

So my new HTC Sensation with T-Mobile arrived today, and I got it for less than $199 it would have cost through T-Mobile direct.

I just thought I would tell you how I got the discount. This discount is not limited to T-Mobile or the HTC Sensation, but is pretty much with any phone you get, and for any company, including Verizon, that you choose to use as your carrier. The discount is different on different phones, but it can save you some money.

Linda Barneck, is an Independent Business Owner in a multi-level-marketing (MLM) company called ACN (Yes, this is the company that was promoted on The Apprentice) but I didn’t get this deal due to family relation. It turns out that anybody who orders through Linda Barneck’s Independent Business Owner site can get this discount.

So click this link and order you new phone with this discount now.

Get your Android Phone at a discount with ACN Wireless Exclusive Deals! 

There are a lot more products that you can get through ACN. You could get a Tablet with a data plan, or a Video Phone, or Satellite TV, or other cool products. See a what products are available in your area here:

Shop for ACN Products & Services

I have personally chosen to not participate directly in MLMs, though I have no problem buying product from an MLM especially if it saves me money, which is what I am doing in this instance. I benefit in no way from you ordering your phone through ACN. My mother did not solicit this post. I am writing this only because I got my phone at a discount.

I almost joined ACN. With ACN being a “techie’s MLM”, I was almost tempted to join. If you are interested in an MLM and you are a bit high-tech, you can become an Independent Business Owner and then buy yourself a new phone through you own account. Just go check out Linda Barneck’s ACN Independent Business Owner page and then click on the “Get Started” link.

 

A Hello World Android App in C#

This post is a continuation of Writing Android apps in C# using MonoDroid.

Writing your first MonoDroid project

Now that you have installed and configured MonoDroid and its prerequisites, you are ready to create your first project.

  1. Open Visual Studio.
  2. Go to File | New | Project.
  3. Choose “Mono for Android”. This is a new project type added by the Mono for Android Visual Studio 2010 Plugin.
  4. Give the project a name and click OK.

You now have a sample MonoDroid app.

Running your first MonoDroid App in an Emulator

Now that you have a sample MonoDroid app, learning to deploy it to an Android device and to test it is the next step.

  1. Simply press F5 in your “Mono for Android” Visual Studio project. The following screen appears however, there are no running Android devices.
  2. Click the link to “Start emulator image”.
  3. Wait until your Android emulator starts and you see the graphical display and not just a text display.
  4. Select your emulator from the Running Devices list and click OK.
  5. Wait. It is going to deploy the mono library to your emulator and deploy your app and this can take time.

You application should now be running in your Android emulator.

This is just a sample application that increments a counter and displays how many times you have click the button.

You are now ready to start writing your own application.

More Tutorials

Xamarin has multiple Tutorials to help you get a little further along.

MonoDroid Tutororials by Xamarin

Writing Android apps in C# using MonoDroid

As C# developers, many of us would prefer to write Android Apps in C# as well. Novell had promised us MonoDroid, but we were quite concerned as to whether MonoDroid would ever be released when Novell was dismantled.

However, Xamarin spawned from the ashes like a phoenix to restore the viability of MonoDroid, restoring our hopes to writing in C# for the Android platform.

Though I am hopeful that MonoDroid will become popular allowing C# to be a commonly used language for Android devices, there is still some question as to whether Xamarin and its MonoDroid product will survive.

Xamarin is a new company and needs to survive first. Its business is to sell MonoDroid, which is not open source, but is a proprietary product. Unfortunately, MonoDroid may cost too much, preventing adoption among app developers. Xamarin requires a customer base and a continual adoption rate if it is going to survive. If the company folds, what is going to happen to the library and the apps that use it?

Is Development with MonoDroid Free? Yes and No!

Yes and no.

Yes because anybody can use and develop with MonoDroid at no cost. It isn’t until you need to publish an app to the app store that you need to buy a license. You can use the MonoDroid trial for as long as you want. Here is a quote from the trial website. [2]

The evaluation version of Mono for Android does not expire, but enables development and testing against the Android Emulator only.

No, because you need to buy a license once either of the following become true:

  1. You need to test your code directly on a real device and not just an emulated device
  2. You are ready to publish an app to the app store

So what is the cost of MonoDroid? Depends on if you buy Professional, Enterprise, or Enterprise Priority. On the Xamarin store, the following table can be found. To see it you have to add MonoDroid to your cart and then click the “Show product comparison” link. [1]

Professional Enterprise Enterprise Priority
Deploy to your devices Has this feature Has this feature Has this feature
Publish to app stores Has this feature Has this feature Has this feature
Enterprise distribution Has this feature Has this feature
Priority support queue Has this feature
Guaranteed response time Has this feature
License expiration Never Never Never
Update subscription 1 Year 1 Year 1 Year
License usage Original User Seat Seat
Price (USD) $399 $999 $2,499

These costs are very low for business or enterprise customers who have C# developers and want to write Android apps.  The cost of training a C# developer to develop apps for Android in Java may be far greater than training them to develop apps for Android using C# and buying a MonoDroid license.

Is MonoDroid easy to set up?

Update
MonoDroid is not down to a one-click installer.

Here is the old method of Installing without the One-click Installer

MonoDroid is simple to set up.  Xamarin has some simple steps that can be found on their web site. They have MonoDroid installation instructions for installing MonoDroid for use with any of three environments.

  1. Visual Studio  (Important! Visual Studio Express is not supported)
  2. MonoDevelop on Windows
  3. MonoDevelop on Mac OSX

If you don’t have a Visual Studio license and you can’t afford one, then go with MonoDevelop because Visual Studio Express is noted to be enough [3].

However, the Visual Studio install is four simple steps.

  1. Install the Java SDK
  2. Install the Android SDK
  3. Configure your simulator
  4. Install the Mono for Android Visual Studio 2010 Plugin

These are very easy steps to complete, and I won’t repeat the steps here, but once you complete them, you are ready to start writing Android apps in C#.

Once you feel you have everything installed, click the following link to continue reading.

Writing your first MonoDroid project

http://android.xamarin.com/Installation/Windows

Smart phones and tablets can’t replace a desktop or laptop, yet!

I completely believe that the phones and tablets like the new T-Mobile 7″ Samsung tab are going to be continue to be huge industries and will not go away as the Palm Pilot did. However, will they continue to explode exponentially as many believe? Or is there a plateau coming?

I just reviewed the Motorola Xoom and it was a great tech toy. However, it wasn’t much more than a casual gaming tool. There is a crucial flaw that has yet to be solved with phones and tablets: Typing.

No matter how fast you can type on a phone or tablet, you will never type as fast as you can on a keyboard. Might there be a solution better than a keyboard that we just haven’t discovered yet…maybe…but even if we discover it will it work on a phone or tablet?

There are certain uses for a phone:

  1. Making calls
  2. MP3 player
  3. Texting
  4. Casual gaming
  5. Visual browsing (such as checking the whether)
  6. Reading email (notice, I didn’t put writing email)
  7. Pocket Portability
  8. GPS and Navigation
  9. Quick low quality photos/video

There are certain uses for a tablet

  1. Book reader
  2. MP3 player
  3. Casual gaming
  4. Visual browsing (such as checking the weather)
  5. Reading email (notice, I didn’t put writing email)
  6. GPS and Navigation
  7. Quick low quality photos/videos

However, will the Laptop and Desktop be taken over by a tablet?  What about 20″ to 27″ monitors? Some of use need so much real-estate we have multiple monitors.  Here are using for a computer that a tablet does not solve.  For those of you thinking of going 100% to phones and tablets, you may just want to hold on.

Here is a list of requirements and uses that are met by a desktop or laptop that the phone and tablet haven’t really solved yet.

Note: I am not going to repeat the items on the list for the smart phones and tables but be aware that the only feature the phone or tablet has that a desktop or laptop doesn’t have today is pocket portability.

  1. Keyboard and typing
    1. Writing email
    2. Writing documents
    3. Creating spreadsheets
    4. Writing code, yes, even writing code for tablets
    5. Writing blog posts (like this one)
  2. CD/DVD/Blu-Ray drive (yes, people are going to still want to play there DVDs and Blu-Ray movies 10 years from now)
  3. Monitors
    1. 17″ or larger monitor
    2. Multiple monitors
    3. Viewing multiple applications simultaneously
  4. Local storage of data.
  5. Serious desktop gaming
    1. Joysticks
    2. Short-cut keys
  6. Peripherals
    1. Printers
    2. External drives
    3. Cameras and Video cameras
    4. Projectors
    5. Custom peripherals (like those that are designed for one company, telescope, craft vinyl cutters, industrial equipment, etc…)
  7. Ethernet, no not everywhere has wireless yet and some secure facilities will never have wireless or allow VPN from a 3G/4G device. Some places don’t allow web-cams or camera devices and unfortunately you can’t take your camera out of your phone or tablet.

We have been using desktops for three decades. Smart-phones and tablets are in their infancy. Many problems, including millions of custom problems for companies in all industries, have been solved using laptops and desktops. To replace desktops and laptops, these problems will have to be solved.

Many problems have solutions already.For example, blue-tooth and wireless technology can allow for peripherals but there are a lot of devices already out there that are not blue-tooth or wireless capable.

But another road block is in the way. Adoption.

Adoptions takes a long time.  First the manufacturers have to adopt a technology, design new products, produce them, distribute them.  Then consumers have to buy the new technology and if they already own an older version, that older version often has to go through its life cycle which can take a lot of years. I still have an HP LaserJet 5L from the late 90s that works perfectly. No, I am not going to invest in another laser printer until this one dies.

So will someone still be running a desktop or laptop with Windows XP/Vista/7 in 2020. Certainly.  Will they probably own a smart phone or tablet as well.  You bet!

Motorola Xoom review – one month later

I had the Motorola Xoom for a month just to experience it. It was provided to me by work but only temporarily.  I just transferred it to a team member so they can now experience it.

If you don’t want to read anything more, and just want me to sum up my review here it is:

I want to buy one now that it is gone but the $599 price overcame my desire as I don’t need one.

So I that means that it is definitely a useful item but it is currently overpriced in my eyes.  I just bought my wife a 17.3″ widescreen HP laptop with a 4GB of RAM, a Blu-Ray, a web-cam, fingerprint reader, HDMI port, etc…It was $549.  Currently there are some Android 2.2 tablets that are in the $100 to $150 range. I think in a year these tablets in the $100-$150 dollar range will be running Android 3.0 or the next version and they will be everything your need.  So only spend the money if you need to.

I am going to own an Android 3.0 device soon, if for no other reason than technology is both my job and hobby so just to stay up to speed with technology, I will need one soon, just not right now.

Ok, let’s get to the positives and negatives.

Negatives

  1. Apps didn’t work until I restored to factory defaults.
  2. Wireless screen didn’t really indicate a scroll bar, took me an hour to figure out I had to scroll down to enter a password.  This was the first thing my team member ran into as well.
  3. Some apps just crash (but many actually updated and started working, so expect app support to improve rapidly)
  4. Learning to type on a touch screen. It is much better than typing on a phone, not as good as a laptop.
  5. Didn’t fit in my suit pocket at church, maybe I should get a 7″ one for myself.
  6. The fingerprints on the screen were annoying and I had to clean it often.

Positives of a tablet

  1. Time to browse.  Once you have your favorite sites, just hitting a site really quick was much faster.
  2. I loved the 10.1 inch screen.
  3. I loved replacing big books.
  4. A good casual game machine, especially for my 3-year-old.

Positives of the Xoom and Android 3

  1. Having about 5 desktops to put icons on.
  2. The first firmware update I received worked perfectly.
  3. Notification system is awesome.
  4. Flash web pages worked just fine.
  5. The email integration with Gmail.
  6. Plenty of disk space. (I never even used 2 GB as much is stored on the cloud)
  7. Multi-threading – It never once felt slow.
  8. Google Maps integration worked well.

Hopefully this review helps you.

The Motorola Xoom is in my hands

I am writing this post to you from a Motorola Xoom.

Typing is definitely harder than with a keyboard yet much easier than from a phone.

It didn’t work out of the box. Apps wouldn’t download, and Google talk wouldn’t connect. I finally factory reset it and started over and it worked. We think you have to log in during the initial configuration to avoid this issue, but we didn’t try to dupe it.

It is working great now.