Wednesday, December 16, 2009

Getting Current Location on Android SDK, requestLocationUpdates

Sorry that I've been MIA for past few month, didn't do any development and I was more focused on life. I am back to android development now and obviously I ran into few problems.

I've spent entire day trying to figure out how to get current location and yet all these forum posts were only giving half of the answer, so i decided to blog about it.

Step 1:
The permission is required on AndroidManifest.xml
please make sure

is there.

Step 2:
Listener is required due to the fact the last known location seems to be null all the time on the emulator. And somehow you need an empty class to accommodate that, I don't know why but it's just the way it is, and you can't declare new LocationListener() for some reason.

public class CurrentLocationListener implements LocationListener{

public void onLocationChanged(Location argLocation) {

}
public void onProviderDisabled(String provider) {
}

public void onProviderEnabled(String provider) {
}

public void onStatusChanged(String provider, int status, Bundle arg2) {
}
}


Step 3:
Declare Location Manager and Listener in order to get current latitude and longitude
in whichever class you decide to write them in.


LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

LocationListener myLocationListener = new CurrentLocationListener();

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1, myLocationListener);

Location currentLocation = locationManager.getLastKnownLocation("gps");

String Latitude = String.valueOf(currentLocation.getLatitude());
String Longitude = String.valueOf(currentLocation.getLongitude());


This worked for me up to this date, if it has any problems feel free to make comment on it.

I'll post about how to get data from wcf next time.

Monday, June 29, 2009

Detention slip, "Thats what she said"


Today my network administrator emailed us this for some fun.

Apple's joke, showing PC as blue screen of death.


So I've been messing around with my Macbook Pro, I've been using finder to access other people's computer to get shared files and such.

But I've noticed something very interesting today, the PC icon on Finder is actually blue screen of death... lol

Wednesday, May 20, 2009

My first Mac, a UniBody MacBook Pro at $1500


After weeks of surfing craigslist, replying to all sort of scams and went to many places to meet up, I've finally managed to buy a Macbook Unibody at $1500 from Mike King, I gave him a great review due to transaction was successful.

The spec is

2.4Ghz Core 2 duo
2GB Ram
250GB 5400RPM hard drive
It sells for $1999 at bestbuy or apple store.

I've always been a PC user, and I still intend to install windows on this Mac, but after using it for one day I've find myself impressed about how much Apple care about their product, from trackpad to the charger, every piece is done with great detail. I shopped in bestbuy for 2 days and the more I look at Mac, the more I enjoy the quality of the product, which eventually made me making the decision on buying the mac.

Throughout all these times searching for DSLR camera and macbook, I've manage to realize that value of an item is only worth it when it exchanges hand without losing its value, and only quality product intend to maintain their value. If I've bought a PC, the moment I buy it anywhere it loses all its value right after, and it just seems so hard to find PC makers making quality product these days, everything is wrapped with cheap plastics which gets overheat very easily.

Wednesday, May 13, 2009

Android SDK's Guide, Image from Gallary to be Clickable

Android's Online Resource is very limited, it took me a day before I can figure out how to make those pictures in the photo gallery clickable. I am still a newbie at android development, but I have never spend this much time trying to figure out something that's this simple.

On the android's website it has Hello Gridview guide, which shows you the photo gallary. If you want further clicks from those photos following code is to be added.

All the XML has already set up in the tutorial.

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView gridview = (GridView) findViewById(R.id.photogridview);
gridview.setAdapter(new ImageAdapter(this));

gridview.setOnItemClickListener(new OnItemClickListener() {
@SuppressWarnings("unchecked")
public void onItemClick(AdapterView parent, View v, int position, long id){
GoDoWhatever();
}}});
}

protected void GoDoWhatever()
{
//Do Whatever you want to do after pictures in the gallery are being clicked
}

Hopefully this helps

Friday, May 8, 2009

Craigslist Spammer, Craigslist Scammer, They should get banned

I've been trying to buy a laptop for a while, hunting deals off slickdeals and fatwallet. California Tax is 9.25%, buying anything off online or retail store feels like getting ripped off because I'd be paying almost 10% more for someone else's irresponsible action. So I decide to get one off craigslist, at least I can bargain down some price off these over priced laptops.

Craigslist Major City such as Los Angeles, New York were filled with spam results when someone search for "HP Pavillion" or "Dell Latitute", even "Apple Macbook Pro". And all these posts will end up with a image on the bottom to show their websites. Most of them are from china with a phone number leaving behind, and their website will make it look like its an actual site.

Buyers be aware, these spammers are also scammers, the site that they direct you is actually scam sites. Do not deal with craigslist seller if you can not meet them in person, do not send them money over any form of transaction other than cash. If you try to save a few bucks on these foreign over sea bargain, you'll end up losing your money without realizing it.

I really hope craigslist would do something about it soon, such as banning proxy sites and sites from foreign countries, this way we'd have some regulation in the system, free of spams and scams.

Thursday, May 7, 2009

I bought Nikon D90, f/3.5-5.6 18-105mm VR kit Lense


I've always wanted a DSLR Camera, but the pricing was just too much for what I can handle. I've browsed through craigslist for past 2 weeks and I've finally found a deal.

Rohit Thakur was selling Nikon D90 with kit 18-105mm f/3.5-5.6 VR Lense for $900, very good deal due to the fact it comes with warranty. So this would be beginning for my photography journey.

Since I've done some research on this camera and lense, I've also played with the camera for past 2 days at different best buy locations. I was pretty happy I picked D90 over D200 even with huge discount on D200, the newer technologies in D90 greatly surpassed the older generation.

The Pros about D90
Its smaller comparing to D200 or D300, feels very comfortable at hand.
It has newer CMOS censoring.
It has 12MP DX images, with the right focus, pictures can zoom in up to a person's skin hair.
It has friendly UI, everything seems straight forward, just by reading guide books you can start taking some good photos.
It has.
It can capture non-professional videos that's just for fun.

The cons about D90
The video capture is at 24fps, which you can see the lag if you are trying to move the camera itself.
The camera zoom lense can go a little further than human eye, so if you want a lense that can zoom far away you'd probably need to get yourself another zoom lense.
The camera package doesn't come with HDMI Cable, in order to connect to your HDTV you'd have to buy one and its not cheap.


Hunting down a good deal requires patience, craigslist sellers intend to sell their items at new price when their items are used, it takes a while before you can find someone that can sell it at a fair price because they want to get rid of the item. I am not a professional photographer, but overall my opinion on this camera is quiet good.

For the past few days I've also gone through some of the older cameras and lense, one thing I did realize was older cameras using stainless steel lenses which was a lot more durable, these days everything is plastic, it just seems that corporates are charging us more and giving us less, just my 2 cents.

Wednesday, May 6, 2009

Android's Button Onclick Event:Button.OnClickListener()

I came from Asp.net background, and I really didn't have any idea on how to develop mobile phone applications. I didn't see any documentation on how get an event for OnClick on Android SDK, this most simple feature is can not be automatically generated by Eclipse, you have do it on your own.

in the \res\layout\main.xml Create the button

<button
id="@+id/TestButton"
layout_width="fill_parent"
layout_height="wrap_content"
layout_marginleft="30dip"
layout_marginright="30dip"
text="Test Button">

And you can reference it like this from code behind

---------------------------------------------------------
package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;

public class HelloAndroid extends Activity {
private Button btnFromGallery;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initControls();
}

protected void initControls()
{
btnFromGallery = (Button)findViewById(R.id.TestButton);

btnFromGallery.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ DoWork(); }});
}

protected void DoWork()
{
//Do whatever you need to do here
}
}
-------------------------------------------------------------------

This may look simple but it was very hard to find it online, I hope google would create more examples in the future.

Conversion to Dalvik format failed with error 1

I started google android development today, after downloading SDK and loading it into eclipse just like how google guide “hello android” has listed.

no classfiles specified
Conversion to Dalvik format failed with error 1
pops up as I try to run it for the very first time.

How you fix it is
Go to Project -> Clean and it should solve the problem.

Good luck on your “Hello Android Application”

Wednesday, January 28, 2009

Asp.net development blog

Well, this is my first post, I've been in web development for a while now and I will keep this blog updated on what I've been doing and some tricks.