0
我有一個工作非常好的代碼。但是,當我運行幾個吧,我的應用程序崩潰,此錯誤:多次運行項目時出錯
03-24 14:47:34.542 3489-3546/com.example.com E/AndroidRuntime﹕ FATAL EXCEPTION: pool-4-thread-1
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
我的代碼:
public class Sample {
public Sample(Context context) {//error for this line
mContext = context.getApplicationContext();}
public void doSignUp(String firstName, String lastName, String userName) {
//some code for signup users
}
}
public class Service {
Runnable task = new Runnable() {
@Override
public void run() {
Sample sample = new Sample(getApplicationContext());
Sample.doSignUp(firstName,lastName,userName);
decreaseCounter();
if(getCounter() <= 0){
stopSelf();
}
}
};
請分享您的代碼 – Ghayel
請發表相關的代碼。 –
我發佈的代碼請注意,它不工作時,幾次運行它,然後當刪除我的項目並重新創建工作 – Tom