Help on Tab Layout example - android

New bee to Android, I need help on creating tabs.
I am following the example stated in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
When I run the application, I am not seeing any tabs but only Songs tab.
I am not able to figure out how to resolve this.
Below code is added under AndriodManifest.xml
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloTabWidget"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".AlbumsActivity">
<intent-filter>
<action android:name="com.example.TabWidget.AlbumsActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".ArtistsActivity">
<intent-filter>
<action android:name="com.example.TabWidget.AlbumsActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SongsActivity">
<intent-filter>
<action android:name="com.example.TabWidget.AlbumsActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

Make it look something like this:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloTabWidget"
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=".AlbumsActivity"/>
<activity android:name=".ArtistsActivity"/>
<activity android:name=".SongsActivity"/>
</application>
This part:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
is for the entry part of your app.

here is a very simple example for tab-layout:
Andorid Tab-Layout with icons

Related

Two apps after react-native run-android

I'm making a react native app and earlier it was working fine but now when I run "react-native run-android", after the successful install and launch, I can see two apps in the simulator and both of them are working fine.
So, any ideas why I'm seeing 2 apps or should I say why I'm getting an extra duplicate app installed?
I think you added splash screen in your app after it you have this problem, first go to this Dir: android/app/src/main/AndroidManifest.xml if you add two time something like this
<activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> -->
it will render two times and build two apps on your device.
in my file
AndroidManifest.xml
<!-- remove just first part the activity, but i comment this part -->
<!-- <activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme"
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=".MainActivity"
android:label="#string/app_name"
android:theme="#style/SplashTheme"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The problem is due to multiple category LAUNCHER in both splash and main activity.
<category android:name="android.intent.category.LAUNCHER" />
The solution with both SplashActivity and MainActivity is to change
<category android:name="android.intent.category.LAUNCHER" />
to
<category android:name="android.intent.category.DEFAULT" />
in MainActivity.
The file with both .SplashActivity and .MainActivity looks like this;
<activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme"
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=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
I had this issue as well. It turns out one of RN lib I installed created an extra <activity /> and <intent-filter />tags. Just check your AndroidManifest.xml.
My source: Running app gives 2 app icons in Android Studio - newbie
Change this
<activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme"
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=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
To
<activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme"
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=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true"
/>
Basically you have two intent-filters delete one
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
To add to the answer Aras posted above, for me the issue was specifically with the extra intent-filter attributes which were labeled 'MAIN' and 'LAUNCHER'. You can't have more than one occurrence of those without creating duplicate apps, it seems.
<activity
android:name=".SplashActivity"
android:theme="#style/SplashTheme"
android:label="#string/app_name">
<!-- You'll either want to remove this section, or ensure that it does not exist in any other activities. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Check the package name of the installed apps.

No Launcher Activity Found even though there is [duplicate]

This question already has answers here:
No Launcher activity found
(2 answers)
Closed 9 years ago.
This is a copy of my AndroidManifest.xml
Any help as to why the launcher is not being recognized? I tried running the code without applying DEFAULT to any other activity but it's still not working.
enter code here
<application
<activity
android:name="project.shirsho.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="project.shirsho.MENU" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="project.shirsho.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.Textplay"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.TEXTPLAY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
You need to specify the MAIN and LAUNCHER in the the intent filter for the activity you want to start on launch by :
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
if you want that Splach Activity as your launcher , your manifest must be :
<application>
<activity
android:name="project.shirsho.Menu"
android:label="#string/app_name" >
</activity>
<activity
android:name="project.shirsho.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="project.shirsho.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.Textplay"
android:label="#string/app_name" >
</activity>
</application>
I believe that you are trying to make "project.shirsho.Menu" as the launcher activity, then it should be like:
<activity
android:name="project.shirsho.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
change,
<intent-filter>
<action android:name="project.shirsho.MENU" />
to
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Hope this helps! :)
This is how your application part should look like. If you use eclipse to develop in it will help you create this (androidManifest.xml)
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
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=".SplashActivity"
android:label="#string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

My App Installs Two Applications - Android

Whenever I try to run my App, it installs two app in the emulator/device. I only want to Install my Main Activity, but the Splash Activity installs also. I know the problem is in the Manifest. Can anyone help me please? Here is my code:
<activity
android:name="com.android.upcurrents.launcher.SplashActivity"
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.android.upcurrents.MainActivity"
android:label="#string/app_name" />
You need to have only one activity to be declared as the launcher. So, remove the intent-filter from within the SplashActivity's tag, and add it to your MainActivity. The Launcher intent-filter should be present in only one of the activities in your manifest file.
It installs based on the intent filter you have provided.
Remove the following intent filter from SplashActivity and then put it in Main Activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
try this:
<activity
android:name="com.android.upcurrents.launcher.SplashActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.android.upcurrents.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I had this same problem but I fixed it with the making sure you only have one activity with:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In my code I had two activities with that intent-filter, which caused two applications to be installed on my device.
We have the same problem but i fixed it this way
before my code below in manifest
<application
android:debuggable="true"
android:allowBackup="true">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.noupdate.apptest_noupdate.MainActivity"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Notice that in the SplashActivity inside the intent is this code
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
i only deleted the category
<category android:name="android.intent.category.LAUNCHER" />
So after i deleted the intent-filter category in splash it didn't install two app icon but only one for main the code will be like this notice that the intent-filter category is deleted
<application
android:debuggable="true"
android:allowBackup="true">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.noupdate.apptest_noupdate.MainActivity"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.NoTitleBar"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
it really helps

How can i use android.intent categories more than one?

Like this: (This is broke)
<activity
android:name="com.example.Main"
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.example.IKI"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.MAINIKI" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.UC"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.MAINUC" />
<category android:name="android.intent.category.**DEFAULT**" />
</intent-filter>
</activity>
Problem is the bold code. How can i use that activity? What is other categories that are choosable? Is there? What should i do?
you may use different activity when you have more than one main activity class in your project.

Android app icon shows on device to allow uninstall but does not allow to execute

I am able to run an android app in two virtual devices when degugging.(Galaxy tab and phone). When I close the app in debug mode the icon is not showing in the virtual device.
The same thing occurs when I load a signed .apk file to the actual devices.
The app icon shows when I go into manage applications. I can uninstall the app. Thats all I can do. I cannot launch the app since the icon is not visible with the other app icons.
I am using platform 2.2 with google api's 8.
What am I doing wrong? How can I get the app icon to show with other apps and be able to launch?
Here is my manifest file.
Any help is appreciated.
<uses-permission
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.INTERNET">
</uses-permission>
<uses-permission
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.ACCESS_FINE_LOCATION">
</uses-permission>
<uses-permission android:name="android.permission.SET_DEBUG_APP"></uses-permission>
<application
android:label="#string/app_name"
android:icon="#drawable/appicon"
android:name=".ApplicationController"
android:debuggable="true" >
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MainActivity"
android:screenOrientation="portrait"
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=".MainFlippingActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MainFlipping" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PrefsTabWidget"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.PrefsTabWidget" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PrefsTaskingActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.PrefsTasking" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SatelliteSelectionActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.SatelliteSelection" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MainSettingsActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MainSettings" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ClassificationActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.Classification" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ListItemPrefActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.ListItemPref" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="TimeOnTargetActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.TimeOnTarget" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="LatLonActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.LatLon" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="QuantityActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.Quantity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="IncidenceAngleActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.IncidenceAngle" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="SendUrlActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.SendUrl" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="TestActivity"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.Test" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Slide"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.Slide" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8"/>
You should only be using <category android:name="android.intent.category.LAUNCHER" /> for one of your activities, not all of them. Try removing all others except the one that goes with <action android:name="android.intent.action.Main" />
EDIT: I may be wrong but I think you'll also need to capitalize MAIN as in <action android:name="android.intent.action.MAIN" /> for it to be recognised as the 'main' entry point (main activity).
Try to remove "android.intent.category.LAUNCHER" for each activity because android project must have only one LAUNCHER activity.
try to this if your main activity use this
<intent-filter>
<action android:name="android.intent.action.Main" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Other activity you can use this
<intent-filter>
<action android:name="android.intent.action.(your action )" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
I think it can be helpful to you .

Categories

Resources