执行到mhandler.sendMessage时软件闪退

package com.loumeng.TCP;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

/**

  • Created by Administrator on 2017/2/15.
    */
    public class TCP_client extends Thread{
    private static final String TAG_1 = "TCPChat";
    private Handler mhandler;
    private Socket socket;
    private boolean isruning;
    public InputStream inputStream;
    public OutputStream outputStream;
    private InetAddress inetAddress; //IP地址
    private int port; //端口号
    public static int CLIENT_STATE_CORRECT_READ=7;
    public static int CLIENT_STATE_CORRECT_WRITE=8; //正常通信信息
    public static int CLIENT_STATE_ERROR=9; //发生错误异常信息
    public static int CLIENT_STATE_IOFO=10; //发送SOCKET信息
    public TCP_client(Handler mhandler) {
    this.mhandler=mhandler;
    isruning=true;
    }

    public void setInetAddress(InetAddress inetAddress) {
    this.inetAddress = inetAddress;
    }
    public void setPort(int port) {
    this.port = port;
    }

    public void getadress(){
    String[] strings = new String[2];
    strings[0]=socket.getInetAddress().getHostAddress();
    strings[1]=socket.getInetAddress().getHostName();
    Message message = mhandler.obtainMessage(CLIENT_STATE_IOFO,-1,-1,strings);
    mhandler.sendMessage(message);
    }

    public void close(){
    if (socket !=null){
    try {
    socket.close();
    socket=null;
    isruning=false;
    } catch (IOException e) {
    }
    }else if (socket ==null){
    Log.e(TAG_1, "未建立连接");
    }
    }
    class Receive_Thread extends Thread{
    private Socket msocket;
    public Receive_Thread (Socket msocket){
    this.msocket =msocket;
    }
    @Override
    public void run() {
    try {
    while (isruning) {
    inputStream = msocket.getInputStream();
    while (inputStream.available()==0){
    }
    try {
    Thread.sleep(200);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    final byte[] buffer = new byte[1024];//创建接收缓冲区

                final int len = inputStream.read(buffer);//数据读出来,并且数据的长度
                mhandler.sendMessage(mhandler.
                        obtainMessage(CLIENT_STATE_CORRECT_READ,len,-1,buffer));
            }
        }catch (IOException e) {
                e.printStackTrace();
               senderror();
            }finally {
            if(msocket!=null){
                try {
                    msocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            try {
            if(inputStream!=null){
                inputStream.close();
            }
            if (outputStream!=null){
                outputStream.close();
            }
            } catch (IOException e) {
                e.printStackTrace();
            }
            Log.e(TAG_1,"关闭连接,释放资源");
        }
    }
    

    }
    public void sendmessage(byte[] message){
    try {
    outputStream =socket.getOutputStream();
    mhandler.sendMessage(mhandler.
    obtainMessage(CLIENT_STATE_CORRECT_WRITE,-1,-1,message));
    outputStream.write(message);

    } catch (IOException e) {
    senderror();
    }
    }

    void senderror(){
    mhandler.sendMessage(mhandler.obtainMessage(CLIENT_STATE_ERROR));
    }
    @Override
    public void run() {
    if(socket == null){
    try {
    Log.e(TAG_1,"启动连接线程");
    socket=new Socket(inetAddress,port);
    new Receive_Thread(socket).start();
    getadress();
    } catch (IOException e) {
    e.printStackTrace();
    senderror();
    }
    }
    }
    }
    以下是问题

2018-12-24 17:21:53.819 29742-29795/? E/d: Failed to find the bundle in BundleInfoList for component null
2018-12-24 17:21:53.861 29742-29795/? E/d: Failed to find the bundle in BundleInfoList for component null
2018-12-24 17:21:54.215 29797-29867/? I/DpmTcmClient: RegisterTcmMonitor from: org.apache.http.impl.conn.TcmIdleTimerMonitor
2018-12-24 17:21:54.225 29797-29797/? E/SQLiteLog: (1) no such table: uni_icon_config
2018-12-24 17:21:54.227 29797-29797/? E/uni_icon_config: no such table: uni_icon_config (code 1): , while compiling: ALTER TABLE uni_icon_config ADD COLUMN text_color TEXT
android.database.sqlite.SQLiteException: no such table: uni_icon_config (code 1): , while compiling: ALTER TABLE uni_icon_config ADD COLUMN text_color TEXT
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
at com.jingdong.common.unification.uniconfig.UnIconTable.upgrade(UnIconTable.java:67)
at com.jingdong.jdsdk.utils.DBHelperUtil$a.onUpgrade(Unknown Source)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.jingdong.jdsdk.utils.DBHelperUtil.getDatabase(Unknown Source)
at com.jingdong.jdsdk.b.a.a.NK(ReminderMigrationHelper.java:38)
at com.jingdong.jdsdk.b.a.bo(DataMagration.java:47)
at com.jingdong.jdsdk.b.a.bn(DataMagration.java:25)
at com.jingdong.app.mall.c.e.onCreate(MainProcessInit.java:124)
at com.jingdong.app.mall.JDAppLike.onCreate(JDAppLike.java:85)
at java.lang.reflect.Method.invoke(Native Method)
at com.tencent.tinker.loader.app.TinkerApplication.onCreate(TinkerApplication.java:180)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
at com.jingdong.aura.core.c.i.callApplicationOnCreate(SourceFile:512)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5637)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:159)
at android.app.ActivityThread.main(ActivityThread.java:6364)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1096)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:883)
2018-12-24 17:21:54.259 29797-29797/? E/SQLiteLog: (1) no such table: JD_ReminderNewTable

1个回答

这不是数据库没有字段值错误了吗

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐