Install by Log Collector Xtralogic Inc
in your code
import android.util.Log;
Log.e("", "failed because " + e);
Run your application on your device
Force the error to happen.
Click on the log collector application - this will prompt you to choose the format you want ( like email to googlemail)
The email will arrive containing your log and your error can be easily seen an interpreted below:
08-16 18:23:46.625 E/JavaBinder( 1104): at dalvik.system.NativeStart.run(Native Method)
08-16 18:23:46.625 W/dalvikvm(10190): threadid=3: thread exiting with uncaught exception (group=0x2aadda10)
08-16 18:23:46.635 E/AndroidRuntime(10190): Uncaught handler: thread main exiting due to uncaught exception
08-16 18:23:46.645 E/AndroidRuntime(10190): java.lang.NullPointerException
08-16 18:23:46.645 E/AndroidRuntime(10190): at com.sampleapp.MainActivity.loadContacts(MainActivity.java:582)
08-16 18:23:46.645 E/AndroidRuntime(10190): at com.sampleapp.MainActivity.getSwitchNumber(MainActivity.java:362)
08-16 18:23:46.645 E/AndroidRuntime(10190): at com.sampleapp.MainActivity.settingsPage(MainActivity.java:271)
08-16 18:23:46.645 E/AndroidRuntime(10190): at com.sampleapp.MainActivity.access$5(MainActivity.java:266)
Monday, 16 August 2010
Tuesday, 10 August 2010
maven debugging
So I know there is a -e switch for debug but if you really want debug, try this
mvn -X compile
mvn -X compile
Tuesday, 3 August 2010
Android 1.6 Reading Contacts name and phone numbers
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(People.CONTENT_URI,
null, null, null, null);
if (cur.getCount() > 0) {
NAMES = new String[cur.getCount()];
int j =0;
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(People._ID));
String name = cur.getString(cur.getColumnIndex(People.DISPLAY_NAME));
NAMES[j] = name;
j++;
Cursor pCur = cr.query(
Contacts.Phones.CONTENT_URI,
null,
Contacts.Phones.PERSON_ID +" = ?",
new String[]{id}, null);
int i=0;
int pCount = pCur.getCount();
String[] phoneNum = new String[pCount];
String[] phoneType = new String[pCount];
while (pCur.moveToNext()) {
phoneNum[i] = pCur.getString(
pCur.getColumnIndex(Contacts.Phones.NUMBER));
phoneType[i] = pCur.getString(
pCur.getColumnIndex(Contacts.Phones.TYPE));
i++;
}
}
}
Cursor cur = cr.query(People.CONTENT_URI,
null, null, null, null);
if (cur.getCount() > 0) {
NAMES = new String[cur.getCount()];
int j =0;
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(People._ID));
String name = cur.getString(cur.getColumnIndex(People.DISPLAY_NAME));
NAMES[j] = name;
j++;
Cursor pCur = cr.query(
Contacts.Phones.CONTENT_URI,
null,
Contacts.Phones.PERSON_ID +" = ?",
new String[]{id}, null);
int i=0;
int pCount = pCur.getCount();
String[] phoneNum = new String[pCount];
String[] phoneType = new String[pCount];
while (pCur.moveToNext()) {
phoneNum[i] = pCur.getString(
pCur.getColumnIndex(Contacts.Phones.NUMBER));
phoneType[i] = pCur.getString(
pCur.getColumnIndex(Contacts.Phones.TYPE));
i++;
}
}
}
Monday, 2 August 2010
Android textview bottom right hand corner
To align your text inside a text view to the bottom right hand corner add this to your TextView tag in the xml file.
android:gravity="right|bottom"
More options available here in the api:
http://developer.android.com/reference/android/R.styleable.html#TextView_gravity
android:gravity="right|bottom"
More options available here in the api:
http://developer.android.com/reference/android/R.styleable.html#TextView_gravity
Adding html code snippet to your eblogger blog
Enter the code here
http://www.blogcrowds.com/resources/parse_html.php
copy the output into your new post
http://www.blogcrowds.com/resources/parse_html.php
copy the output into your new post
Android 2 ways to hide the title bar
In the code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
In the AndroidManifest.xml
<activity android:name=".YourClassNameHere"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
In the AndroidManifest.xml
<activity android:name=".YourClassNameHere"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
Friday, 30 July 2010
Forwarded to me from a friend
class fun {
public static void main(String[] args)
{
Integer a=10; Integer b=10; Integer c=1000; Integer d=1000;
System.out.println(a==b);//true
System.out.println(c==d);//false }
};
http://www.owasp.org/index.php/Java_gotchas#Immutable_Objects_.2F_Wrapper_Class_Caching
http://tech.puredanger.com/2007/02/01/valueof/
class fun {
public static void main(String[] args)
{
Integer a=10; Integer b=10; Integer c=1000; Integer d=1000;
System.out.println(a==b);//true
System.out.println(c==d);//false }
};
http://www.owasp.org/index.php/Java_gotchas#Immutable_Objects_.2F_Wrapper_Class_Caching
http://tech.puredanger.com/2007/02/01/valueof/
Wednesday, 28 July 2010
Why did my eclipse crash ?
I just found out the log files for eclipse live in the
workspace_directory/.metadata/.log
If your wondering why your eclipse crashed this might help you track down the issue.
workspace_directory/.metadata/.log
If your wondering why your eclipse crashed this might help you track down the issue.
PermGen Error Eclipse 3.5.2 jdk 1.6.0_21
java.lang.OutOfMemoryError: PermGen space
So I had to get a pc rebuilt at work and had to reinstall everything. I downloaded Eclipse Galileo IDE for Java EE Developers from here :
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/galileosr2
and the latest sdk from sun which at the time was 6 update 21
I then added the Android eclipse plugin and set it up as normal.
I started to create a HelloWorld Android application and found eclipse repeatedly crashed and froze up, almost 20 times, when I was doing basic editing.
I tried removing the mylyn plugin but this made no difference so then I tried jdk 6 update 20 and this resolved my issue.
http://java.sun.com/products/archive/j2se/6u20/index.html
http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F
which states
The Eclipse 3.3 - 3.6 launchers for Windows have a problem with the Oracle/Sun Java VM version '1.6.0_21'. You have three choices to work around this:
1. switch back to '1.6.0_20' (as of July 19, 2010 it can still be downloaded here)
2. Change the commandline for launching or add the following line after "-vmargs" to your eclipse.ini file:
-XX:MaxPermSize=256m
(Detailed instructions/examples)
3. For Helios, download the fixed eclipse_1308.dll and place it into
(eclipse_home)/plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503
helps if I RTM
So I had to get a pc rebuilt at work and had to reinstall everything. I downloaded Eclipse Galileo IDE for Java EE Developers from here :
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/galileosr2
and the latest sdk from sun which at the time was 6 update 21
I then added the Android eclipse plugin and set it up as normal.
I started to create a HelloWorld Android application and found eclipse repeatedly crashed and froze up, almost 20 times, when I was doing basic editing.
I tried removing the mylyn plugin but this made no difference so then I tried jdk 6 update 20 and this resolved my issue.
http://java.sun.com/products/archive/j2se/6u20/index.html
http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F
which states
The Eclipse 3.3 - 3.6 launchers for Windows have a problem with the Oracle/Sun Java VM version '1.6.0_21'. You have three choices to work around this:
1. switch back to '1.6.0_20' (as of July 19, 2010 it can still be downloaded here)
2. Change the commandline for launching or add the following line after "-vmargs" to your eclipse.ini file:
-XX:MaxPermSize=256m
(Detailed instructions/examples)
3. For Helios, download the fixed eclipse_1308.dll and place it into
(eclipse_home)/plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503
helps if I RTM
Subscribe to:
Posts (Atom)