after Using with AsynchUtil App getting Terminated and Ended. I don't know Why ?
Show complete code.
@SimpleFunction(description = "")
public void printPOS(final String Tabs) {
AsynchUtil.runAsynchronously(new Runnable() {
@Override
public void run() {
bgPrint(Tabs) ;
}
});
}
/* //Its Working ...
@SimpleFunction(description = "Threded Functon")
public void printPOS(final String Tabs) {
form.runOnUiThread(new Runnable() {
@Override
public void run() {
bgPrint(Tabs) ;
}
});
}*/
@SimpleFunction(description = "Printing Future")
public void bgPrint(String Tabs) {
bgQTotal = 0;
bgTotal = 0;
bgGrand_Total = 0;
bgDiscount = 0;
bgDiscount_in_Per = 0;
List11.clear();
List12.clear();
List13.clear();
List14.clear();
bgIns = getDB(Tabs);
float bgFqty = 0;
boolean bgbint = false;
for(int i=0;i< Ins.size();i++){
if(bgbint){
bgFqty = Float.parseFloat(bgIns.get(i));
bgQuentity.add(String.format("%.1f", bgFqty));
}else{
bgFqty = Float.parseFloat(bgIns.get(i+1));
bgItem.add(bgIns.get(i));
GetRateOfItem(bgIns.get(i));
bgRate.add( String.format("%.2f",RateFromTDB));//50 is Temperary rate
bgAmount.add(String.format("%.2f",RateFromTDB * bgFqty));
}
bgbint=!bgbint;
}
//int LengthCheck = Item.size();
for(int i=0;i< bgQuentity.size();i++){
bgQTotal = bgQTotal + Float.parseFloat(bgQuentity.get(i));
}
for(int i=0;i< bgAmount.size();i++){
bgTotal = bgTotal + Float.parseFloat(bgAmount.get(i));
}
bgPrint();
}
You can't update views or give commands from background thread.
Call bgPrint
inside form.runOnUiThread
method.
Ok I try
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.