1This is my code snippet
TabHost tabHost = getTabHost();
TabSpec aboutus = tabHost.newTabSpec("About us");
aboutus.setIndicator("___", getResources().getDrawable(R.drawable.icon_aboutus_tab));
Intent photosIntent = new Intent(getApplicationContext(), readmore.class);
aboutus.setContent(photosIntent);
TabSpec contactus = tabHost.newTabSpec("Contact us");
// setting Title and Icon for the Tab
contactus.setIndicator("___", getResources().getDrawable(R.drawable.icon_contactus_tab));
Intent songsIntent = new Intent(getApplicationContext(), contactus.class);
contactus.setContent(songsIntent);
TabSpec orderhistory = tabHost.newTabSpec("Order history");
orderhistory.setIndicator("___", getResources().getDrawable(R.drawable.icon_orderhistory_tab));
Intent videosIntent = new Intent(getApplicationContext(), readmore.class);
orderhistory.setContent(videosIntent);
TabSpec home = tabHost.newTabSpec("Home");
home.setIndicator("___", getResources().getDrawable(R.drawable.icon_home_tab));
Intent homeIntent = new Intent(getApplicationContext(), Mainpage.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
home.setContent(homeIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(aboutus); // Adding about us tab
tabHost.addTab(contactus); // Adding contact us tab
tabHost.addTab(orderhistory); // Adding order history tab
tabHost.addTab(home);
The Intent is not overriding the main activity.
how am i supposed to override it.
This is my manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidhive.xmlparsing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="#drawable/zaggleicon"
android:label="#string/app_name"
android:name=".MyApplication"
android:theme="#android:style/Theme.Light"
>`<activity
android:label="#string/app_name"
android:name=".AndroidTabLayoutActivity" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>`<activity
android:label="#string/app_name"
android:name=".readmore" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>` <activity android:name=".Mainpage">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>`<activity
android:label="#string/app_name"
android:name=".contactus" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>`
From my image it is showing that when i press the button the activit is showing in particular portion and the last activity remains same in the activity.So how to override that activty when i press the tab button.
Simply declare you tab's activities as per below -
<activity
android:label="#string/app_name"
android:name=".readmore"> </activity>
<activity android:name=".Mainpage"></activity>
<activity
android:label="#string/app_name"
android:name=".contactus" ></activity>
And, have a look at TabLayout tutorial.
Related
I have an app A and an app B, I'm trying to open an app B activity from app A, which is not the main activity.
I know there are already lot of answers on this subject, but I can't manage to make any of these work, this is why I'm asking for help.
First here is the "simplified" manifest of the app B (the one that has to be opened) :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rlaville.gestionsav" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".Vues.CreationSav"
android:windowSoftInputMode="stateHidden"
android:noHistory="true">
</activity>
<activity android:name=".Vues.GestionSav" android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Vues.StatSav" android:noHistory="true">
</activity>
<activity android:name=".Vues.ModifierSav" android:noHistory="true" android:windowSoftInputMode="stateHidden" android:exported="true" >
<action android:name="com.example.rlaville.gestionsav.MODIFY_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</activity>
<provider
android:name=".Donnees.SavDataProvider"
android:authorities="com.example.rlaville.gestionsav.Donnees.SavDataProvider"
android:exported="true"
></provider>
</application>
</manifest>
The activity I want to open is ModifierSav, so I did put an intent filter inside of it as it is said to do in every tutorial.
Then I've tried these methods in the other app :
Directly calling the intent filter name :
Intent i = new Intent("com.example.rlaville.gestionsav.MODIFY_ACTIVITY");
i.putExtra("CurrentSavID", itemId);
startActivity(i);
Or using a packageManager :
public boolean openSavApp(Context ctx, String packageName, long itemId){
PackageManager manager = ctx.getPackageManager();
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
return false;
//throw new PackageManager.NameNotFoundException();
}
i.putExtra("CurrentSavID", itemId);
ctx.startActivity(i);
return true;
}
that I tried to call like this
openSavApp(getActivity(), "com.example.rlaville.gestionsav.MODIFY_ACTIVITY", itemId);
What am I doing wrong? What should I do to be able to open this specific activity from the other app?
You have missed <intent-filter> tag.
<activity android:name=".Vues.ModifierSav" android:noHistory="true" android:windowSoftInputMode="stateHidden" android:exported="true" >
<action android:name="com.example.rlaville.gestionsav.MODIFY_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</activity>
change this to
<activity android:name=".Vues.ModifierSav" android:noHistory="true" android:windowSoftInputMode="stateHidden" android:exported="true" >
<intent-filter>
<action android:name="com.example.rlaville.gestionsav.MODIFY_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Update:
you are getting null intent because you are not providing the correct package name here.
you have provide here this package name which you mentioned in manifest tag.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rlaville.gestionsav" >
public boolean openSavApp(Context ctx, String packageName, long itemId){
PackageManager manager = ctx.getPackageManager();
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
return false;
//throw new PackageManager.NameNotFoundException();
}
i.putExtra("CurrentSavID", itemId);
ctx.startActivity(i);
return true;
}
<intent-filter>
<action android:name="com.example.rlaville.gestionsav.MODIFY_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
You've forgot to put action and category inside intent-filter block.
I have problem with my manifest. When I try to open the second Activity, I get the error android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION }
Find bellow my Manifest .xml contain
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxxxx.monapplication" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:supportsRtl="true" android:theme="#style/AppTheme" >
<activity android:name="com.xxxxx.monapplication.application.Accueil" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.xxxxx.monapplication.application.OwnerRegistration" >
<intent-filter>
<action android:name="android.intent.action.APPLICATION.OWNERREGISTRATION" />
<category android:name="android.intent.category.APPLICATION.DEFAULT" />
</intent-filter>
</activity>
An the part of my code to open second activity
btnMel.setOnClickListener( new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent i = new Intent("com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION");
startActivity(i);
}
}
Please help me to find the error.
You can call activity by its class name, then put your custom intent to setAction.
private String YOUR_ACTION = "com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION"
//uou can use this instead.
//Intent i = new Intent(this /* caller context */, OwnerRegistration.class);
Intent i = new Intent();
i.setAction(YOUR_ACTION);
startActivity(i);
try this code..
Intent myIntent = new Intent(YourActivity.this, OWNERREGISTRATION.class); startActivity(myIntent);
I have a splash screen with a timer that runs for 3 seconds. After the 3 seconds it is supposed to auto load another activity called Dashboard. I made a new class that I want to have load after the splash screen called WelcomeSplash. I changed the classes in the splash screen from Dashboard to WelcomeSplash and the app force closes and the logcat says it has a null point exception. Here is the snip of code from the splash class and logcat snip.
02-13 23:18:46.826: E/AndroidRuntime(2475): FATAL EXCEPTION: main
02-13 23:18:46.826: E/AndroidRuntime(2475): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.magicbuddy.gamble/com.magicbuddy.gamble.welcomeSplash}:
java.lang.NullPointerException
02-13 23:18:46.826: E/AndroidRuntime(2475): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
Here is the snip of the Splash code
startActivity(new Intent(Splash.this, welcomeSplash.class));
When I change the welcomeSPlash.class to Dashboard.class the app does not force close. Here is the welcomeSplash Activity,
public class welcomeSplash extends Activity implements OnClickListener {
Button btnskip;
Button btnplay;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
btnskip =(Button) findViewById(R.id.btnSkip);
btnskip.setOnClickListener(this);
btnplay =(Button) findViewById(R.id.btnOk);
btnplay.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnSkip:
Intent a = new Intent(welcomeSplash.this, Dashboard.class);
startActivity(a);
break;
case R.id.btnOk:
Intent i = new Intent(welcomeSplash.this, Profile.class);
startActivity(i);
break;
}
}
}
THe manifest is copied below too.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.magicbuddy.gamble"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.magicbuddy.gamble.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.magicbuddy.gamble.welcomeSplash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.magicbuddy.gamble.Dashboard" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.magicbuddy.gamble.Dashboard"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.Player"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.Menu"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.Popup"
android:label="#string/title_activity_popup" >
</activity>
</application>
</manifest>
Remove this code from your menifest
<intent-filter>
<action android:name="com.magicbuddy.gamble.Dashboard" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
07-18 04:48:22.465: E/AndroidRuntime(19105): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.liamwli.fa.yearbook/com.liamwli.fa.yearbook.Home}: java.lang.NullPointerException
That is the error I get.
I have defined the Home class in the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.liamwli.fa.yearbook"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Home"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo" >
<intent-filter>
<action android:name="com.liamwli.fa.yearbook.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
And it only started doing this when I added the putExtras line in my main activity:
enter.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
myname = name.getText().toString();
Intent i = new Intent("com.liamwli.fa.yearbook.HOME");
i.putExtra("myname", myname);
startActivity(i);
}
});
So, can anyone please explain what is happening?
use this:
Intent i = new Intent(context,otherActivity.class);
context of that activity from where you want to start activity.otherActivity is the name of activity which you want to start
Try this once
Intent i = new Intent(MainActivity.this,Home.class);
i.putExtra("myname", myname);
startActivity(i);
And I don't think this is required in Manifest
<intent-filter>
<action android:name="com.liamwli.fa.yearbook.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
change like this
Intent i = new Intent(MainActivity.this, Home.class);
i.putExtra("myname", myname);
startActivity(i);
Try this...
Intent i = new Intent( YourActivityName.this , otherActivity.class);
Ok, I looked and it looked like I was setting a variable contents outside of the onCreate method. So that is why it wasn't working.
I have already lost 2 days in this problem, please provide any help you can.
I have an Android application which displays 2 Android Activity icons: "Comp 1" and "Comp 2".
Both "Comp 1" and "Comp 2" shows TabActivities with tabs within.
Problem:
Right after deploying my application, I can enter into any of "Comp 1" or "Comp 2" TabActivity, but when I leave the activity and when I try to enter the other TabActivity, the tabs shown are the same from the previous one "Comp 1" or "Comp 2" it always depends on which I start first.
Objective:
For any of the "Comp N", open correctly the tabs assigned on the TabActivities(see code on this post).
Please, allow me to show my code.
I will show AndroidManifest.xml, TabActivity for "Comp 1" and TabActivity for "Comp 2". They're a bit extensive, so I apologize in advance for any extra and unnecessary info they may contain. I just didn't want to take risk to forget to provide any important information on the 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 for standard MMComponentTabAssembler tab view.
Use this code to include new components activities that extend from 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 for 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 to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
//Multimodal component tab
intent = new Intent().setClass(this, GPS.class);
intent.addCategory(Const.COMPONENT_CATEGORY_GPS); //Used to produce Intents to the MMComponent
intent.addCategory(Const.ACTIVITY_CATEGORY_GPS); //Used to consume Intents on the BroadcastReceiver associated to the Activity
// Initialize a TabSpec for each tab and add it to the 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 a TabSpec for each tab and add it to the 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 to produce Intents to the MMComponent
intent.addCategory(Const.ACTIVITY_CATEGORY_GPS); //Used to consume Intents on the BroadcastReceiver associated to the 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 to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, NetworkDispatcher1.class);
// Initialize a TabSpec for each tab and add it to the 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 one of activity set
And others should set something else, such as
Then only one activity assigned the icon.