android - How to use WebView in a tab and call "(LocalActivityManager activityGroup)"? -


i have 3 tabs want use utilize 3 webviews display specific domains. builds find when try launch app force closes when run & if debug -- stays open layout , views (it nothing when debugging.)

logcat says

unable start activity componentinfo{com.company.client/com.company.client.mainactivity}: java.lang.illegalstateexception: did forget call 'public void setup(localactivitymanager activitygroup)'?**

how call that?

heres code:

import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.menu; import android.widget.tabhost; import android.widget.tabhost.tabspec;  public class mainactivity extends activity { tabhost th;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     th = (tabhost) findviewbyid(r.id.tabhost);     th.setup();       tabspec firstspec=th.newtabspec("classes & events");     firstspec.setindicator("classes & events", null);     intent firstintent= new intent(this, webviewactivity.class);     firstintent.putextra("backswipe", false);     firstspec.setcontent(firstintent);     th.addtab(firstspec);      tabspec secondspec=th.newtabspec("twitter");     secondspec.setindicator("twitter", null);     intent secondintent= new intent(this, webviewactivity2.class);     secondspec.setcontent(secondintent);     th.addtab(secondspec);      tabspec thirdspec=th.newtabspec("facebook");     thirdspec.setindicator("facebook", null);     intent thirdintent= new intent(this, webviewactivity3.class);     thirdspec.setcontent(thirdintent);     th.addtab(thirdspec); }    @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true;  }  } 

the webview code

import android.os.bundle; import android.app.activity; import android.view.menu; import android.webkit.webview;  public class webviewactivity extends activity {  public webview webview_a;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);        webview_a = (webview) findviewbyid(r.id.tab1);     webview_a.getsettings().setjavascriptenabled(true);     webview_a.loadurl("http://www.eventbrite.com");  }    @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.web_view, menu);     return true; }  } 

the xml main layout

<?xml version="1.0" encoding="utf-8"?> <tabhost xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffb84d" >  <linearlayout     android:id="@+id/linearlayout1"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >      <tabwidget         android:id="@android:id/tabs"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_marginbottom="-3dip"         android:layout_weight="0" >     </tabwidget>      <framelayout         android:id="@android:id/tabcontent"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_weight="1" >     </framelayout> </linearlayout>  </tabhost> 

heres logcat.

05-23 01:23:06.886: w/dalvikvm(14673): threadid=1: thread exiting uncaught exception (group=0x4160e930) 05-23 01:23:06.910: e/androidruntime(14673): fatal exception: main 05-23 01:23:06.910: e/androidruntime(14673): java.lang.runtimeexception: unable start activity componentinfo{com.company.client/com.company.client.mainactivity}: java.lang.illegalstateexception: did forget call 'public void setup(localactivitymanager activitygroup)'? 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activitythread.performlaunchactivity(activitythread.java:2307) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2357) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activitythread.access$600(activitythread.java:153) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activitythread$h.handlemessage(activitythread.java:1247) 05-23 01:23:06.910: e/androidruntime(14673): @ android.os.handler.dispatchmessage(handler.java:99) 05-23 01:23:06.910: e/androidruntime(14673): @ android.os.looper.loop(looper.java:137) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activitythread.main(activitythread.java:5226) 05-23 01:23:06.910: e/androidruntime(14673): @ java.lang.reflect.method.invokenative(native method) 05-23 01:23:06.910: e/androidruntime(14673): @ java.lang.reflect.method.invoke(method.java:511) 05-23 01:23:06.910: e/androidruntime(14673): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:795) 05-23 01:23:06.910: e/androidruntime(14673): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:562) 05-23 01:23:06.910: e/androidruntime(14673): @ dalvik.system.nativestart.main(native method) 05-23 01:23:06.910: e/androidruntime(14673): caused by: java.lang.illegalstateexception: did forget call 'public void setup(localactivitymanager activitygroup)'? 05-23 01:23:06.910: e/androidruntime(14673): @ android.widget.tabhost$intentcontentstrategy.getcontentview(tabhost.java:747) 05-23 01:23:06.910: e/androidruntime(14673): @ android.widget.tabhost.setcurrenttab(tabhost.java:413) 05-23 01:23:06.910: e/androidruntime(14673): @ android.widget.tabhost.addtab(tabhost.java:240) 05-23 01:23:06.910: e/androidruntime(14673): @ com.company.client.mainactivity.oncreate(mainactivity.java:28) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activity.performcreate(activity.java:5104) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 05-23 01:23:06.910: e/androidruntime(14673): @ android.app.activitythread.performlaunchactivity(activitythread.java:2261) 05-23 01:23:06.910: e/androidruntime(14673): ... 11 more

so, how can webviewactivities acitive in tabs , logcat tells me to?

first mistake noticed is, trying set content after adding tab:

   tabspec firstspec=th.newtabspec("classes & events");    firstspec.setindicator("classes & events", null);    intent firstintent= new intent(this, webviewactivity.class);    th.addtab(firstspec);    firstspec.setcontent(firstintent); 

it should be:

   tabspec firstspec=th.newtabspec("classes & events");    firstspec.setindicator("classes & events", null);    intent firstintent= new intent(this, webviewactivity.class);    firstspec.setcontent(firstintent);    th.addtab(firstspec); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -