android application does not show in the recent application tab - android

When i use the Label attribute in the manifest for an activity, it does not show in the recent application list. Code for activity in manifest file is:
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/MyTheme"
android:icon="#drawable/ic_launcher"
android:label=""
>
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
when i use android:label="#string/app_name" , then it start showing in the recent tab, but i dont want activity label.

Your application is not visible in recent apps list because label of your main activity is empty.
Change
<activity... android:label="">
To
<activity... android:label="#string/some_name">
Edit:
If you don't want to show label for your activity then do the following.
You must set android:label="#string/some_name" in <activity> tag
And then write getActionBar().setDisplayShowTitleEnabled(false); in onCreate() method of your activity you want to hide label of.
This will let you hide the activity label and will show your app in recent apps list as well.

Related

How to insert an android activity into the manifest given in a tutorial?

I am very new to android development with eclipse, and I encounter dozen of errors and problems. Here is the next one:
I am following an android tutorial given here in order to set up the action bar. In this tutorial is says to insert an activity as follows:
<activity android:theme="#style/Theme.AppCompat.Light" ... >
Can I just put this line into the xml manifest file?
<activity android:theme="#style/Theme.AppCompat.Light">
Or do I need to replace the '...' by something more useful?
Please read the docs: activity-element
The activity's name is required, so you would need to have:
<activity android:theme="#style/Theme.AppCompat.Light" android:name="MyActivity">
Other than that, you are not required to add any other attributes.
Although be sure to place the activity element within the proper place in your xml. It should be contained in your application block:
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light">
<activity android:name="MyActivity"
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>
Unless you really want your app to work under API levels under 3.0 then you have to add it like this.
android:theme="#style/Theme.AppCompat.Light"
Inside your already defined activity in your manifest (the one that has the intent filter and other declarations).
otherwise you dont have to add that at all.
This is one example.
<activity
android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.Light"
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>
and this is another
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme=#style/Theme.AppCompat.Light"" >
<activity android:name=".DetailActivity"
android:label="#string/app_name" >
</activity>
The second way you posted is just fine, be sure to close the activity tag so it looks like <activity android:theme="#style/Theme.AppCompat.Light"></activity>
Also, if you're using eclipse, it is easier to go into the AndroidManifest and under the Application tab scroll to the bottom where there's Application Nodes and then add your view from there. Eclipse will auto generate the correct code in the xml file.

Setting two different labels for the Launcher and the first activity

This should be a simple fix. My problem is that my launcher name is the same as my first activity. #string/app_name is my actual application name that I want it to show, but it is showing my first activity "Drafts" for the launcher. If I take out the #string/activity_drafts then the Launcher is correct, but then the first activity is my app_name which is not the behaviour I am looking for. I just want two seperate names for the launcher and the first activity's title and I'm not really sure what is going on here.
Manifest.xml
<application android:name="com.jordan.dictation.Dictation2Go"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/dp_launcher2"
android:logo="#drawable/dp_white_logo"
android:label="#string/app_name"
android:theme="#style/MyTheme">
<activity
android:name="com.jordan.dictation.Draft_Activity"
android:screenOrientation="portrait"
android:label="#string/activity_drafts"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am not sure how to do it in manifest file, however you can do it programmatically in your activity:
setTitle("Activity title");
or
getActionBar().setTitle("Activity title");
EDIT: GOT IT!
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name="com.example.so1.MainActivity"
android:label="ACTIVITY NAME"
>
<intent-filter android:label="APP NAME">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Note: Doing this might result in unexpected behavior upon device restart, e.g. with an unmodified Samsung S3, a shortcut on the home screen will be renamed to the activity's label. (See https://stackoverflow.com/a/7250902)
The icon and label set for an intent filter are used to
represent a component whenever the component is
presented to the user as fulfilling the function advertised
by the filter. For example, a filter with
" android.intent.action.MAIN " and
" android.intent.category.LAUNCHER " settings
advertises an activity as one that initiates an
application — that is, as one that should be displayed in
the application launcher. The icon and label set in the
filter are therefore the ones displayed in the launcher.

Activity label appears on home screen instead of app name

In AndroidManifest.xml, the application tag has:
android:label="#string/app_name"
and app_name in res/values/strings.xml reads "My App".
But after running or debugging on both the emulator and an attached device, the app icon on the home screen displays the main activity's label instead of the app label. Is this expected behavior, and if not why might it be happening?
Yes it is Expected behavior. The app name will be seen in the applications tab in settings. The main screen displays the launcher activity's label.
If you want to display the app_name property as the label of your application below the launcher icon you can specify the android:label property in the application tag of your android manifest file.
For example:
<application
android:name=".MyApp"
android:icon="#drawable/myIcon"
android:label="#string/app_name">
A workaround for this behaviour:
In manifest:
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In MainActivity's onCreate:
getSupportActionBar().setTitle(R.string.activity_name);
By doing this, the app name will appear on home screen, and you can still have a different title for your launcher activity.
People see here, I got the same issue and finally resolve it.
Launcher show only the mainActivity because activity label is preferred for Phone Launcher.
So one want show Application labe rather than MainActivity's, he should delete the line:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
delete this:
android:label="#string/title_activity_main"

Can I set the name of the app to something other than the label of the activity with the intent-filter?

I have an app with four activities. I have set the intent-filter on one of them so it will be displayed first to the user when he starts the app. It has a label that says "Add expense".
Now the name under the icon for the app in the phone says "Add expense".
I would like the activities to have their different labels because they are displayed in the menu at the top of each activity and help the user understand what the activity is about. But I want the app name to be something other than the label of the activity with the intent-filter.
Is that possible?
Part of my manifest:
As you can see I've tried to set android:label="#string/app_name" on the application level but that doesn't work. The label on the activity is displayed under the icon anyway.
<application
android:icon="#drawable/ic_money_bag"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light" >
<activity
android:name=".AddExpenseActivity"
android:label="#string/add_expense_header" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListExpensesActivity"
android:label="#string/list_expenses_header" >
</activity>
<activity
android:name=".AddExpenseAccountActivity"
android:label="#string/add_expense_account_header" />
<activity
android:name=".ListExpenseAccountsActivity"
android:label="#string/list_expense_accounts_header" />
</application>
Regards,
Mattias
You can use setTitle(String s) in each activity to change the name that appears in the title bar dynamically. So for you setting it in onCreate to whatever you want might suffice.
setTitle("Hello StackOverflow");
Try giving
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
When the label is specified for the activity then i will be shown with the same label in Launcher
What can u do is give label to intent-filter

How to name Android Application

I have an Android App with 2 activities. I have the following in the AndroidManifest:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="false">
<activity android:name=".MyCellTracker" android:label="#string/activity1_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DisplaySuccess" android:label="#string/activity2_name"></activity>
The activities are properly named, yet the application is using the project name rather than the android:label (#string/app_name) I have given it. If I go to delete the application, then I see that it is named using the android:label. Why is the name that is displayed under the icon on the program launcher not using android:label in the application node?
This may not be the answer you're looking for, but you can set the activity title using setTitle(string title).
Set the title programmatically, and set the app title in the manifest.xml using the main activity's label.
According to that reference:
http://developer.android.com/guide/topics/manifest/activity-element.html#label
it is the label of the main activity. However if you don't set a label in the activity, the label of the application is taken.

Categories

Resources