Featured post
Android: Multiple TabActivities problem -
i have lost 2 days in problem, please provide can. have android application displays 2 android activity icons: "comp 1" , "comp 2". both "comp 1" , "comp 2" shows tabactivities tabs within. problem: right after deploying application, can enter of "comp 1" or "comp 2" tabactivity, when leave activity , when try enter other tabactivity, tabs shown same previous 1 "comp 1" or "comp 2" depends on start first. objective: of "comp n", open correctly tabs assigned on tabactivities(see code on post).
please, allow me show code. show androidmanifest.xml, tabactivity "comp 1" , tabactivity "comp 2". they're bit extensive, apologize in advance , unnecessary info may contain. didn't want take risk forget provide important information on first post.
androidmanifest.xml ("comp 1"=mmcomponenttabassembler, "comp 2"=tabassembler)
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versioncode="1" android:versionname="1.0" android:installlocation="internalonly" package="be.multitel.android.mmnd"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps" /> <activity android:name=".activity.tabassembler" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".activity.networkdispatcher1" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <activity android:name=".activity.device" android:label="@string/app_test_device_name"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <activity android:name=".activity.sms" android:label="@string/sms_app_name"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <activity android:name=".activity.networkdispatcheractivity" android:label="@string/test_network_dispatcher_app_name"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <!-- begin :: code standard mmcomponenttabassembler tab view. use code include new components activities extend mmsupercomponent. --> <activity android:name=".activity.mmcomponenttabassembler" android:label="comp 1" android:theme="@android:style/theme.notitlebar"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".activity.gps" android:label="gps"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <activity android:name=".activity.gpspreferences" android:label="gpsprefs"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <activity android:name=".activity.standardsetupactivity" android:label="setup"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.tab" /> </intent-filter> </activity> <!-- end :: code standard mmcomponenttabassembler tab view. --> <service android:exported="true" android:name=".service.networkdispatcherservice" android:process=":remote"> <intent-filter> <action android:name="networkdispatcherservice"> </action> </intent-filter> </service> <service android:exported="true" android:name=".service.nethubservice" android:process=":remote"/> <receiver android:name=".service.utils.networklistener"> <intent-filter> <action android:name= "android.net.conn.connectivity_change" /> <action android:name= "android.provider.telephony.sms_received" /> <action android:name= "be.multitel.android.mmnd.service.utils.socketlistener.ack_received" /> </intent-filter> </receiver> <receiver android:name=".service.utils.mmnetworkdispatcherreceiver" > <intent-filter> <action android:name= "android.net.conn.connectivity_change" /> <action android:name= "connectivity_change" /> <action android:name= "android.provider.telephony.sms_received" /> <action android:name= "be.multitel.android.mmnd.service.utils.socketlistener.ack_received" /> </intent-filter> </receiver> <receiver android:name=".service.utils.mmreceiver" > <intent-filter> <action android:name="action_mm_connect" /> <action android:name="action_mm_disconnect" /> <action android:name="action_event_cmd_dispatcher_accesreq" /> <action android:name="action_event_cmd_dispatcher_accesrelease" /> <action android:name="action_event_cmd_dispatcher_accesinforeq" /> <action android:name="action_event_cmd_dispatcher_bwinforeq" /> <action android:name="action_event_cmd_dispatcher_latencyinforeq" /> <category android:name="component_category_gps"/> </intent-filter> </receiver> </application> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.send_sms" /> <uses-permission android:name="android.permission.receive_sms"/> <uses-permission android:name="android.permission.access_fine_location"/>
"comp 1" tabactivity = mmcomponenttabassembler
public class mmcomponenttabassembler extends tabactivity { public static final string tag = mmcomponenttabassembler.class.getname(); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.standard_tabbed_pane); resources res = getresources(); // resource object drawables tabhost tabhost = gettabhost(); // activity tabhost tabhost.tabspec spec; // resusable tabspec each tab intent intent; // reusable intent each tab //multimodal component tab intent = new intent().setclass(this, gps.class); intent.addcategory(const.component_category_gps); //used produce intents mmcomponent intent.addcategory(const.activity_category_gps); //used consume intents on broadcastreceiver associated activity // initialize tabspec each tab , add tabhost spec = tabhost.newtabspec("gps").setindicator("gps", res.getdrawable(r.drawable.ic_tab_gps)) .setcontent(intent); tabhost.addtab(spec); //preferences tab intent = new intent().setclass(this, gpspreferences.class); // initialize tabspec each tab , add tabhost spec = tabhost.newtabspec("gpsprefs").setindicator("gpsprefs", res.getdrawable(r.drawable.ic_tab_gpsprefs)) .setcontent(intent); tabhost.addtab(spec); //standard setup tab intent = new intent().setclass(this, standardsetupactivity.class); intent.addcategory(const.component_category_gps); //used produce intents mmcomponent intent.addcategory(const.activity_category_gps); //used consume intents on broadcastreceiver associated activity spec = tabhost.newtabspec("standard_setup_tab").setindicator("setup", res.getdrawable(r.drawable.ic_tab_standard_setup)) .setcontent(intent); tabhost.addtab(spec); tabhost.setcurrenttab(0); } @override protected void onresume() { super.onresume(); log.d(tag,"activity group lifecicle :: onresume()."); } @override protected void onpause() { super.onpause(); log.d(tag,"activity group lifecicle :: onpause()."); } @override protected void onstop() { super.onstop(); log.d(tag,"activity group lifecicle :: onstop()."); } @override protected void ondestroy() { super.ondestroy(); log.d(tag,"activity group lifecicle :: ondestroy()."); }
}
"comp 2" tabactivity = tabassembler
public class tabassembler extends tabactivity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main_tab); resources res = getresources(); // resource object drawables tabhost tabhost = gettabhost(); // activity tabhost tabhost.tabspec spec; // resusable tabspec each tab intent intent; // reusable intent each tab intent = new intent().setclass(this, networkdispatcher1.class); // initialize tabspec each tab , add tabhost spec = tabhost.newtabspec("netword_dispatcher").setindicator("ndispatcher", res.getdrawable(r.drawable.ic_tab_mmnd)) .setcontent(intent); tabhost.addtab(spec); intent = new intent().setclass(this, device.class); spec = tabhost.newtabspec("test_device").setindicator("test device", res.getdrawable(r.drawable.ic_tab_test_device)) .setcontent(intent); tabhost.addtab(spec); intent = new intent().setclass(this, sms.class); spec = tabhost.newtabspec("test_sms").setindicator("sms", res.getdrawable(r.drawable.ic_tab_sms)) .setcontent(intent); tabhost.addtab(spec); intent = new intent().setclass(this, networkdispatcheractivity.class); spec = tabhost.newtabspec("test_network_dispatcher").setindicator("test nd", res.getdrawable(r.drawable.ic_tab_test_network_dispatcher)) .setcontent(intent); tabhost.addtab(spec); tabhost.setcurrenttab(3); }
}
only 1 of activity set , others should set else, such 1 activity assigned icon.
- Get link
- X
- Other Apps
Comments
Post a Comment