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
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.
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.
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
Right-click on your package and choose New | Class.
Provide a class name and click ok.
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
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.
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
In Eclipse, select File | New Project | Android | Android Project.
Give your project a Name.
I named this project “HelloAll”.
Select the Build Target (the minimum version of Android).
I selected Android 2.2.
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.
Click Finish.
Your project is now created.
Step 2 – Add an XML file for the menu
Expand the res directory in your project.
Right-click on the layout folder and choose New | Other.
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:
You now have a menu and strings for each menu item.
Step 4 – Overload onCreateOptionsMenu
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);
}
}
Add code to override onCreateOptionsMenu and add code to inflate the menu.
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
Add code to override onOptionsItemSelected and add code to inflate the menu.
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.
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.
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:
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
Turn your Bluetooth on, and make sure it’s discoverable. Do this for each device.
On either device, scan for or add a new Bluetooth device.
Connect/Pair the two devices.
Enter the pin in both devices to pair them.
Step 2 – Send the Contacts
On your old RAZR V3m, select Contacts on your phone.
Select Options.
Scroll all the way to the bottom of that ridiculous list. See the one that says, “Send Name Card.” Select it.
Only one card will have been selected (likely the first on your contacts list). Hit the “Add” softkey option, and select “Add All.”
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.
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
Click on the bottom left icon to go to All Apps.
Scroll down and select Settings.
Click on Wireless & Networks.
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
On your computer (I used Windows 7) click Add device from your Bluetooth options.
Windows searches for you device. Click it when it is found.
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
On your laptop, in the Bluetooth device control window, click the link under file transfer: “Send files to your (HTC Sensation 4G) phone”.
Click Browse Files.
Add all the .vcf files that you previously transferred to this folder: C:\Users\UserName\Documents\Bluetooth Exchange Folder
Click Send.
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
On your HTC Sensation 4G, click Contacts.
Click the second icon below the screen (has one longer horizontal line above three shorter horizontal lines).
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.
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:
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.
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:
You need to test your code directly on a real device and not just an emulated device
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
Publish to app stores
Enterprise distribution
Priority support queue
Guaranteed response time
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.
Visual Studio (Important! Visual Studio Express is not supported)
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.
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:
Making calls
MP3 player
Texting
Casual gaming
Visual browsing (such as checking the whether)
Reading email (notice, I didn’t put writing email)
Pocket Portability
GPS and Navigation
Quick low quality photos/video
There are certain uses for a tablet
Book reader
MP3 player
Casual gaming
Visual browsing (such as checking the weather)
Reading email (notice, I didn’t put writing email)
GPS and Navigation
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.
Keyboard and typing
Writing email
Writing documents
Creating spreadsheets
Writing code, yes, even writing code for tablets
Writing blog posts (like this one)
CD/DVD/Blu-Ray drive (yes, people are going to still want to play there DVDs and Blu-Ray movies 10 years from now)
Monitors
17″ or larger monitor
Multiple monitors
Viewing multiple applications simultaneously
Local storage of data.
Serious desktop gaming
Joysticks
Short-cut keys
Peripherals
Printers
External drives
Cameras and Video cameras
Projectors
Custom peripherals (like those that are designed for one company, telescope, craft vinyl cutters, industrial equipment, etc…)
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!
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
Apps didn’t work until I restored to factory defaults.
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.
Some apps just crash (but many actually updated and started working, so expect app support to improve rapidly)
Learning to type on a touch screen. It is much better than typing on a phone, not as good as a laptop.
Didn’t fit in my suit pocket at church, maybe I should get a 7″ one for myself.
The fingerprints on the screen were annoying and I had to clean it often.
Positives of a tablet
Time to browse. Once you have your favorite sites, just hitting a site really quick was much faster.
I loved the 10.1 inch screen.
I loved replacing big books.
A good casual game machine, especially for my 3-year-old.
Positives of the Xoom and Android 3
Having about 5 desktops to put icons on.
The first firmware update I received worked perfectly.
Notification system is awesome.
Flash web pages worked just fine.
The email integration with Gmail.
Plenty of disk space. (I never even used 2 GB as much is stored on the cloud)
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.