繁体   English   中英

在死线程上向消息处理程序发送消息调用Mysql连接时出错

[英]Sending message to a Handler on a dead thread Error while calling Mysql connection

我已经调用了一种方法,该方法连接到Mysql以上传数据并获取此错误。 我也尝试了新线程,但没有任何好处。 我阅读了许多与吐司留言有关的类似问题。 你能建议如何处理吗? 方法称为扩展到IntentService的类的onHandleintent。

这是我的代码:

public class LocalService extends IntentService {


    public LocalService() {
        super("LocalService");
    }

    double sal;
    double var;
    int deviceid = 20;


    private String datepattern = "dd-MMM-yyyy";
    String date = new SimpleDateFormat(datepattern).format(new Date());
    String timepat = "hh-mm-ss aa";
    String time = new SimpleDateFormat(timepat).format(new Date());

    @Override
    protected void onHandleIntent(Intent intent) {

            new Thread(new Runnable() {
                @Override
                public void run() {
                    uploadtoserver();
                }
            }).start();

        } 
    }

解决了 我创建了公共void onStart(){},并将整个代码放在此处,而使onHandleIntent方法为空。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM