I have a code like this running on Android 2.3.3 (Nexus One)
for(i=0; i<1000; i++){
for(j=0;j<1000;j++){
do AND calculation
do XOR calculation
}
}
Is this too much calculation for android? I went through the debugger and the debugger lost its control after 3 iteration of the first for loop (3000 iteration tota开发者_JAVA技巧l)
I am running this on a new thread like this and call this function on main ui thread..
public void startCalculation(ArrayList<data> featA, ArrayList<data> featB){
newThread= new Thread(new Runnable(){
public void run(){
theFunction();
}
});
newThread.start();
}
Thanks in advance...
Yeah it seems likely that the process monitor killed your application because it was unresponsive. Keep long running operations off the UI thread.
Do not do this on UI thread ... use Threads or AsyncTasks for long running operations
EDITed:
for debug use logcat ... just add
Log.d("Some My Tag", "Debuging value of smth is:" + value);
and then read values from Logcat's window in Eclipse
You will get a ANR (Application not responding) error if you carry out long running operations on the UI thread. You should do your heavy duty work in background threads.
精彩评论