java - Couldn't parse the HTML tags from live site in android -
we working on power shut down app in android domain particular region.so need live update details url.so need html tags live site.we got nothing.
for example in app title live url , put in text view code comes here.we using jsoup values.
package com.example.poweralert.app; import java.io.file; import java.io.ioexception; import java.io.inputstream; import java.lang.annotation.documented; import java.util.arraylist; import java.util.arrays; import java.util.hashmap; import java.util.list; import android.app.progressdialog; import android.provider.documentscontract; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.listadapter; import android.widget.radiobutton; import android.widget.radiogroup; import android.widget.simpleadapter; import android.widget.textview; import android.widget.toast; import android.content.intent; import android.widget.arrayadapter; import android.widget.listview; import android.widget.relativelayout; import android.widget.relativelayout.layoutparams; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import org.jsoup.jsoup; import org.jsoup.nodes.element; import org.jsoup.select.elements; import org.jsoup.nodes.document; public class primaryactivity extends actionbaractivity { private radiogroup radiooptiongroup; private radiobutton radiooptiobtn; private button btndisplay; /*public string loadjsonfromasset() { string json = null; try { inputstream = getassets().open("locate.json"); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); json = new string(buffer, "utf-8"); } catch (ioexception ex) { ex.printstacktrace(); return null; } return json; }*/ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_primary); string title=null; document document; try { document= jsoup.connect("https://www.facebook.com/") .useragent("mozilla/5.0 (windows; u; windowsnt 5.1; en-us; rv1.8.1.6) gecko/20070725 firefox/2.0.0.6") .referrer("http://www.google.com") .get(); title=document.title(); textview text=(textview)findviewbyid(r.id.textview); text.settext(title); } catch (exception e) { e.printstacktrace(); log.d("tag","document"); } /*list<string> formlist= new arraylist<string>(); try { jsonobject jsonobject = new jsonobject(loadjsonfromasset()); jsonarray jsonarray = jsonobject.getjsonarray("manali"); (int = 0; < jsonarray.length(); i++) { jsonobject jo_inside = jsonarray.getjsonobject(i); if (jo_inside.has("location")) { formlist.add(jo_inside.getstring("location")); } } listview listview = (listview) findviewbyid(r.id.listview1); listview.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, formlist)); } catch (jsonexception e) { e.printstacktrace(); }*/ button button= (button) findviewbyid(r.id.btndis); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { } }); }
}
how show live url site title in text view.the above code shows nothing.
myhtml
<textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textview" android:text="html text" android:layout_below="@+id/searchview" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_marginleft="85dp" android:layout_margintop="50dp" /> </relativelayout>
also got in log cat when running app
04-03 12:29:11.123 26083-26083/com.example.ipower.app d/dalvikvm﹕ zygote::forkandspecialize : 0 04-03 12:29:11.124 26083-26083/com.example.ipower.app d/dalvikvm﹕ zygote new systemtid : 26083 04-03 12:29:11.124 26083-26083/com.example.ipower.app d/dalvikvm﹕ late-enabling checkjni 04-03 12:29:11.127 26083-26083/com.example.ipower.app d/jdwp﹕ prepping jdwp on adb 04-03 12:29:11.127 26083-26083/com.example.ipower.app d/jdwp﹕ adb transport startup 04-03 12:29:11.127 26083-26086/com.example.ipower.app d/dalvikvm﹕ elevating priority 0 -8 04-03 12:29:11.127 26083-26087/com.example.ipower.app d/jdwp﹕ jdwp: thread running 04-03 12:29:11.130 26083-26087/com.example.ipower.app d/jdwp﹕ acceptconnection 04-03 12:29:11.130 26083-26087/com.example.ipower.app d/jdwp﹕ trying receive file descriptor adb 04-03 12:29:11.143 26083-26087/com.example.ipower.app d/jdwp﹕ received file descriptor 40 adb 04-03 12:29:11.144 26083-26083/com.example.ipower.app d/dalvikvm﹕ zygote thread init done 04-03 12:29:11.148 26083-26087/com.example.ipower.app d/jdwp﹕ processincoming 04-03 12:29:11.148 26083-26087/com.example.ipower.app d/jdwp﹕ processincoming 04-03 12:29:11.148 26083-26087/com.example.ipower.app d/jdwp﹕ handlepacket : cmd=0x1, cmdset=0xc7, len=0x13, id=0x40000024, flags=0x0, datalen=0x8 04-03 12:29:11.162 26083-26087/com.example.ipower.app d/jdwp﹕ processincoming 04-03 12:29:11.162 26083-26087/com.example.ipower.app d/jdwp﹕ handlepacket : cmd=0x1, cmdset=0xc7, len=0x17, id=0x40000025, flags=0x0, datalen=0xc 04-03 12:29:11.170 26083-26087/com.example.ipower.app d/jdwp﹕ processincoming 04-03 12:29:11.170 26083-26087/com.example.ipower.app d/jdwp﹕ handlepacket : cmd=0x1, cmdset=0xc7, len=0x13, id=0x40000026, flags=0x0, datalen=0x8 04-03 12:29:11.176 26083-26087/com.example.ipower.app d/jdwp﹕ processincoming 04-03 12:29:11.176 26083-26087/com.example.ipower.app d/jdwp﹕ handlepacket : cmd=0x1, cmdset=0xc7, len=0x13, id=0x40000027, flags=0x0, datalen=0x8 04-03 12:29:11.715 26083-26083/com.example.ipower.app d/jdwp﹕ sendbufferedrequest : len=0x3d 04-03 12:29:12.295 26083-26083/com.example.ipower.app d/jdwp﹕ sendbufferedrequest : len=0x47 04-03 12:29:12.464 26083-26083/com.example.ipower.app w/asset﹕ assetmanager-->adddefaultassets cip path not exsit! 04-03 12:29:13.130 26083-26083/com.example.ipower.app w/system.err﹕ android.os.networkonmainthreadexception 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ android.os.strictmode$androidblockguardpolicy.onnetwork(strictmode.java:1128) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ java.net.inetaddress.lookuphostbyname(inetaddress.java:385) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ java.net.inetaddress.getallbynameimpl(inetaddress.java:236) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ java.net.inetaddress.getallbyname(inetaddress.java:214) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpconnection.<init>(httpconnection.java:70) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpconnection.<init>(httpconnection.java:50) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpconnection$address.connect(httpconnection.java:340) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpconnectionpool.get(httpconnectionpool.java:87) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpconnection.connect(httpconnection.java:128) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpengine.opensocketconnection(httpengine.java:316) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpengine.connect(httpengine.java:311) 04-03 12:29:13.139 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpengine.sendsocketrequest(httpengine.java:290) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpengine.sendrequest(httpengine.java:240) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpurlconnectionimpl.connect(httpurlconnectionimpl.java:81) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:449) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:434) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection.execute(httpconnection.java:181) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection.get(httpconnection.java:170) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ com.example.ipower.app.mainactivity.oncreate(mainactivity.java:29) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activity.performcreate(activity.java:5122) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1081) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.performlaunchactivity(activitythread.java:2307) 04-03 12:29:13.140 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.handlelaunchactivity(activitythread.java:2395) 04-03 12:29:13.141 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.access$600(activitythread.java:162) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread$h.handlemessage(activitythread.java:1364) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ android.os.handler.dispatchmessage(handler.java:107) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ android.os.looper.loop(looper.java:194) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.main(activitythread.java:5371) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ java.lang.reflect.method.invokenative(native method) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ java.lang.reflect.method.invoke(method.java:525) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) 04-03 12:29:13.142 26083-26083/com.example.ipower.app w/system.err﹕ @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 04-03 12:29:13.143 26083-26083/com.example.ipower.app w/system.err﹕ @ dalvik.system.nativestart.main(native method) 04-03 12:29:13.143 26083-26083/com.example.ipower.app i/system.out﹕ [cds] fix other exception in httpurlconnection 04-03 12:29:13.143 26083-26083/com.example.ipower.app w/system.err﹕ java.io.ioexception 04-03 12:29:13.143 26083-26083/com.example.ipower.app w/system.err﹕ @ libcore.net.http.httpurlconnectionimpl.connect(httpurlconnectionimpl.java:87) 04-03 12:29:13.143 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:449) 04-03 12:29:13.143 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:434) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection.execute(httpconnection.java:181) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ org.jsoup.helper.httpconnection.get(httpconnection.java:170) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ com.example.ipower.app.mainactivity.oncreate(mainactivity.java:29) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activity.performcreate(activity.java:5122) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1081) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.performlaunchactivity(activitythread.java:2307) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.handlelaunchactivity(activitythread.java:2395) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.access$600(activitythread.java:162) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread$h.handlemessage(activitythread.java:1364) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.os.handler.dispatchmessage(handler.java:107) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.os.looper.loop(looper.java:194) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ android.app.activitythread.main(activitythread.java:5371) 04-03 12:29:13.144 26083-26083/com.example.ipower.app w/system.err﹕ @ java.lang.reflect.method.invokenative(native method) 04-03 12:29:13.145 26083-26083/com.example.ipower.app w/system.err﹕ @ java.lang.reflect.method.invoke(method.java:525) 04-03 12:29:13.145 26083-26083/com.example.ipower.app w/system.err﹕ @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) 04-03 12:29:13.145 26083-26083/com.example.ipower.app w/system.err﹕ @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 04-03 12:29:13.145 26083-26083/com.example.ipower.app w/system.err﹕ @ dalvik.system.nativestart.main(native method) 04-03 12:29:13.171 26083-26083/com.example.ipower.app v/phonewindow﹕ decorview setvisiblity: visibility = 4 04-03 12:29:14.790 26083-26083/com.example.ipower.app v/phonewindow﹕ decorview setvisiblity: visibility = 0 04-03 12:29:14.919 26083-26083/com.example.ipower.app d/libegl﹕ loaded /system/lib/egl/libegl_mali.so 04-03 12:29:14.936 26083-26083/com.example.ipower.app d/libegl﹕ loaded /system/lib/egl/libglesv1_cm_mali.so 04-03 12:29:14.941 26083-26083/com.example.ipower.app d/libegl﹕ loaded /system/lib/egl/libglesv2_mali.so 04-03 12:29:15.013 26083-26083/com.example.ipower.app d/openglrenderer﹕ enabling debug mode 0
Comments
Post a Comment