Tuesday, November 18, 2008

How to connect G1 GPhone Android T-Mobile with Computer via USB

This is really a simple task.
Just connect USB with you gphone and you computer via USB cable.
Then in the phone's notification area (on top the screen). Drag all the notifications out and there is a notification about USB. Click it and a pop up will ask you to "mount" or "unmount". Click mount and you can copy things in and out of G1's SD card between you computer and the phone.

GL

Monday, November 17, 2008

Error from debugger: Error launching remote program: security policy error

I paid $99 and became an iPhone developer today.
When I tried to run a program on iPhone, I got the following error:
"Error from debugger: Error launching remote program: security policy error" in the xcode.
I followed exactly the steps of it.

Later, I found this is a really stupid small mistake.
In xcode, Groups & Files -> Targets -> xxxxx (xxxxx is your project name). Highlight it and click Info (command + i). 
In the "Properties" tab, there is an "Identifier" field. DEFAULT VALUE IS WRONG!!!
You need you use your own one that you use in creating an app id.
In iPhone Developer Program's program portal page. Click App IDs. Each id will look like this
"XXXXXXXXXX.com.mywebsitename"
XXXXXXXXXX is the nenerated bundle id.
In the "Identifier" filed of "Properties" tab, type "com.mywebsitename".
If this is not consistent with the one used in program portal page, when you try to launch program. "Error from debugger: Error launching remote program: security policy error" will be prompted.

How come Apple give such an stupid error that gives no information at all???

Recently I'm struggling with Apple and iPhone.
If I have a chance to choose whether to choose iPhone as my development platform, I will definitely say "NO!". I would rather use QBASIC in "文曲星" (a small computing device famous in China)

Tuesday, November 4, 2008

Convert Human Readable Time Format to Unix Time & Java Milliseconds ( (Java Code))

I just wrote a java program to convert Human Readable Time Format to Unix Time & Java Milliseconds ( (Java Code)).
The code can be accessed here.
I also put it as follows to make it searchable:
To test it, you can convert the milliseconds back to human readable time format here.

//Created on Nov 4, 2008 5:31:17 PM
//Author : Junxian Huang
package iperf;

public class HjxTimeConverter {
public static void main(String[] argv){
System.out.println("Time converter works");
//long milli = HjxTimeConverter.getMilliseconds(1986, 6, 11, 16, 20, 0, 0, -5);
long milli = HjxTimeConverter.getMilliseconds(2008, 11, 4, 18, 22, 0, 0, -5);
//long milli = HjxTimeConverter.getMilliseconds(1970, 2, 2, 2, 15, 1, 1, -5);
System.out.println(milli);
System.out.println(System.currentTimeMillis());
}
public static final int BASE_YEAR = 1970;
public static final int BASE_MONTH = 1;
public static final int BASE_DAY = 1;
public static final int BASE_HOUR = 0;
public static final int BASE_MINUTE = 0;
public static final int BASE_SECOND = 0;
public static final long MILLI_IN_A_SECOND = 1000;
public static final long MILLI_IN_A_MINUTE = 60 * MILLI_IN_A_SECOND;
public static final long MILLI_IN_A_HOUR = 60 * MILLI_IN_A_MINUTE;
public static final long MILLI_IN_A_DAY = 24 * MILLI_IN_A_HOUR;
public static final long MILLI_IN_MONTH[] = {
0, //A pad
31 * MILLI_IN_A_DAY,
28 * MILLI_IN_A_DAY,//For leap year, we add one day
31 * MILLI_IN_A_DAY,
30 * MILLI_IN_A_DAY,
31 * MILLI_IN_A_DAY,
30 * MILLI_IN_A_DAY,
31 * MILLI_IN_A_DAY,
31 * MILLI_IN_A_DAY,
30 * MILLI_IN_A_DAY,
31 * MILLI_IN_A_DAY,
30 * MILLI_IN_A_DAY,
31 * MILLI_IN_A_DAY
};
/**
* @author Junxian Huang
* @Time Created on Nov 4, 2008 5:31:17 PM
* Given time is local time based on the supplied time zone
* @param year
* @param month
* @param day
* @param hour : hour should in 24 hour format, e.g. 8pm should be 20, 12am (midnight) is 0, 12pm (noon) is 12
* @param minute
* @param second
* @param millisecond
* @param time_zone : Number follows GMT for your time zone.
* For Ann Arbor (EST which is GMT -5, time_zone = -5)
* @return Java Milliseconds
* You can check this using the online converter here (http://www.munc.com/jseffects/timeConverter.html)
*/
public static long getMilliseconds(int year, int month, int day, int hour, int minute, int second, int millisecond, int time_zone){

long milli = 0;
int i;
for(i = BASE_YEAR ; i <>
if(i % 4 == 0){
//For leap year
milli += 366 * MILLI_IN_A_DAY;
}else{
milli += 365 * MILLI_IN_A_DAY;
}
}
for(i = BASE_MONTH ; i <>
if(year % 4 == 0 && i == 2){
//For leap year, February
milli += MILLI_IN_MONTH[i] + MILLI_IN_A_DAY;
}else{
milli += MILLI_IN_MONTH[i];
}
}
for(i = BASE_DAY ; i <>
milli += MILLI_IN_A_DAY;
}
for(i = BASE_HOUR ; i <>
milli += MILLI_IN_A_HOUR;
}
for(i = BASE_MINUTE ; i <>
milli += MILLI_IN_A_MINUTE;
}
for(i = BASE_SECOND ; i <>
milli += MILLI_IN_A_SECOND;
}
milli += millisecond;
milli -= time_zone * MILLI_IN_A_HOUR; //We should subtract here!
return milli;
}
}