Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 解析isn';t工作-安卓_Android_Parsing - Fatal编程技术网

Android 解析isn';t工作-安卓

Android 解析isn';t工作-安卓,android,parsing,Android,Parsing,我有下面的parse类用于在数据库函数中进行搜索,但解析不起作用。显示“无法解析”toast。 加上logcat没有显示任何错误,所以我无法指定导致toast显示的部分 public class Parser extends AsyncTask <Void, Void,Integer> { Context ctx; String data; ListView listView; ArrayList<String> titles = new

我有下面的parse类用于在数据库函数中进行搜索,但解析不起作用。显示“无法解析”toast。 加上logcat没有显示任何错误,所以我无法指定导致toast显示的部分

public class Parser extends AsyncTask <Void, Void,Integer> {

    Context ctx;
    String data;
    ListView listView;
    ArrayList<String> titles = new ArrayList<>();


    public Parser (Context ctx, String data, ListView listView){
        this.ctx=ctx;
        this.data=data;
        this.listView=listView;
    }
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Integer doInBackground(Void... params) {
        return this.parse();
    }

    @Override
    protected void onPostExecute(Integer integer) {
        super.onPostExecute(integer);

        if (integer == 1){

            ArrayAdapter adapter = new ArrayAdapter(ctx, android.R.layout.simple_list_item_1, titles);
            listView.setAdapter(adapter);
        }else {
            Toast.makeText(ctx, "Unable to Parse", Toast.LENGTH_LONG).show();
        }
    }

    private int parse (){
        try {
            JSONArray ja = new JSONArray(data);
            JSONObject jo = null;

            titles.clear();

            for (int i = 0; i < ja.length(); i++){
                jo=ja.getJSONObject(i);
                String title = jo.getString("post_title");
                titles.add(title);
            }

            return  1;
        } catch (JSONException e) {
            e.printStackTrace();

        }

        return 0;
    }
}
公共类解析器扩展异步任务{
上下文ctx;
字符串数据;
列表视图列表视图;
ArrayList titles=新的ArrayList();
公共解析器(上下文ctx、字符串数据、ListView ListView){
这个.ctx=ctx;
这个。数据=数据;
this.listView=listView;
}
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
}
@凌驾
受保护的整数doInBackground(Void…params){
返回this.parse();
}
@凌驾
受保护的void onPostExecute(整数){
onPostExecute(整数);
如果(整数==1){
ArrayAdapter=新的ArrayAdapter(ctx,android.R.layout.simple\u list\u item\u 1,标题);
setAdapter(适配器);
}否则{
Toast.makeText(ctx,“无法解析”,Toast.LENGTH_LONG.show();
}
}
私有整数解析(){
试一试{
JSONArray ja=新JSONArray(数据);
JSONObject jo=null;
标题。清除();
对于(int i=0;i
日志

03-17 19:09:53.246 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:viewPostimeiInputStage进程指针0
03-17 19:09:53.306 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:viewPostimeiInputStage进程指针1
03-17 19:09:53.446 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:MSG_RESIZED:ci=Rect(0,96-0,1128)vi=Rect(0,96-0,1128)或=1
03-17 19:09:54.296 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:#1 mView=com.android.internal.policy.PhoneWindow$DecorView{145fd86 V.E……R……I.0,0,0}
03-17 19:09:54.306 13705-14599/com.example.joudialfattal.skillsexchange I/System.out:(HTTPLog)-静态:isSBSettingEnabled false
03-17 19:09:54.306 13705-14599/com.example.joudialfattal.skillsexchange I/System.out:(HTTPLog)-静态:isSBSettingEnabled false
03-17 19:09:54.306 13705-13705/com.example.joudialfattal.skillsChange W/DisplayListCanvas:DisplayListCanvas在未索引的RenderNode上启动(无mOwningView)
03-17 19:09:54.326 13705-13733/com.example.joudialfattal.skillsexchange D/mali_winsys:EGLint new_window_surface(egl_winsys_display*,void*,eglssurface,EGLConfig,egl_winsys_surface**,egl_color_buffer_format*,EGLBoolean)返回0x3000,[1592x909]-格式:1
03-17 19:09:54.336 13705-13705/com.example.joudialfattal.skillsChange W/DisplayListCanvas:DisplayListCanvas在未索引的RenderNode上启动(无mOwningView)
03-17 19:09:54.376 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:MSG_RESIZED_REPORT:ci=Rect(0,0-0,0)vi=Rect(0,0-0,0)或=1
03-17 19:09:54.616 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:#3 mView=null
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:org.json.JSONException:输入结束于
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:org.json.JSONTokener.syntaxError(JSONTokener.java:449)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:org.json.JSONTokener.nextValue(JSONTokener.java:97)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:org.json.JSONArray.(JSONArray.java:92)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:org.json.JSONArray.(JSONArray.java:108)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at com.example.joudialfattal.skillsexchange.Parser.parse(Parser.java:58)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at com.example.joudialfattal.skillsexchange.Parser.doInBackground(Parser.java:39)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at com.example.joudialfattal.skillsexchange.Parser.doInBackground(Parser.java:18)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at android.os.AsyncTask$2.call(AsyncTask.java:295)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:at java.lang.Thread.run(Thread.java:818)
03-17 19:09:54.696 13705-13705/com.example.joudialfattal.skillsChange E/ViewRootImpl:sendUserActionEvent()mView==null
03-17 19:09:54.706 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl:#1 mView=android.widget.LinearLayout{864f1d1 V.E………I.0,0-0,0}
03-17 19:09:54.766 13705-13733/com.example.joudialfattal.skillsexchange D/mali_winsys:EGLint新窗口表面(egl_winsys_display*、void*、eglssurface、EGLConfig、egl_winsys_表面**、egl_颜色缓冲区格式*、EGLBoolean)re
03-17 19:09:53.246 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: ViewPostImeInputStage processPointer 0
03-17 19:09:53.306 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: ViewPostImeInputStage processPointer 1
03-17 19:09:53.446 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 96 - 0, 1128) vi=Rect(0, 96 - 0, 1128) or=1
03-17 19:09:54.296 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{145fd86 V.E...... R.....I. 0,0-0,0}
03-17 19:09:54.306 13705-14599/com.example.joudialfattal.skillsexchange I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-17 19:09:54.306 13705-14599/com.example.joudialfattal.skillsexchange I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-17 19:09:54.306 13705-13705/com.example.joudialfattal.skillsexchange W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
03-17 19:09:54.326 13705-13733/com.example.joudialfattal.skillsexchange D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1592x909]-format:1
03-17 19:09:54.336 13705-13705/com.example.joudialfattal.skillsexchange W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
03-17 19:09:54.376 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
03-17 19:09:54.616 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: #3 mView = null
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err: org.json.JSONException: End of input at character 0 of 
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at org.json.JSONTokener.nextValue(JSONTokener.java:97)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at org.json.JSONArray.<init>(JSONArray.java:92)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at org.json.JSONArray.<init>(JSONArray.java:108)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at com.example.joudialfattal.skillsexchange.Parser.parse(Parser.java:58)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at com.example.joudialfattal.skillsexchange.Parser.doInBackground(Parser.java:39)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at com.example.joudialfattal.skillsexchange.Parser.doInBackground(Parser.java:18)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
03-17 19:09:54.636 13705-14614/com.example.joudialfattal.skillsexchange W/System.err:     at java.lang.Thread.run(Thread.java:818)
03-17 19:09:54.696 13705-13705/com.example.joudialfattal.skillsexchange E/ViewRootImpl: sendUserActionEvent() mView == null
03-17 19:09:54.706 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: #1 mView = android.widget.LinearLayout{864f1d1 V.E...... ......I. 0,0-0,0}
03-17 19:09:54.766 13705-13733/com.example.joudialfattal.skillsexchange D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [637x181]-format:1
03-17 19:09:54.776 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
03-17 19:09:54.776 13705-13705/com.example.joudialfattal.skillsexchange W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
03-17 19:09:54.806 13705-13733/com.example.joudialfattal.skillsexchange V/RenderScript: 0x7f690b1000 Launching thread(s), CPUs 8
03-17 19:09:58.206 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: #3 mView = null
03-17 19:10:28.296 13705-13705/com.example.joudialfattal.skillsexchange W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
03-17 19:10:28.346 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
03-17 19:10:28.516 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
03-17 19:10:28.606 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getExtractedText on inactive InputConnection
03-17 19:10:28.606 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
03-17 19:10:28.606 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
03-17 19:10:28.676 13705-13705/com.example.joudialfattal.skillsexchange V/ActivityThread: updateVisibility : ActivityRecord{6fcff37 token=android.os.BinderProxy@267e99f {com.example.joudialfattal.skillsexchange/com.example.joudialfattal.skillsexchange.FindSkill}} show : true
03-17 19:10:28.716 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
03-17 19:10:28.716 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
03-17 19:10:28.716 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
03-17 19:10:28.716 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: getExtractedText on inactive InputConnection
03-17 19:10:28.716 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
03-17 19:10:28.716 13705-13705/com.example.joudialfattal.skillsexchange W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
03-17 19:10:29.176 13705-13705/com.example.joudialfattal.skillsexchange D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1