Set Title To Hidden on Android App - android

In my android app, I want to hide the app name from the view, as shown in the image on the left, but if you expand away, the app name to be displayed, as shown in the picture in the right. However, my current way to show the left image is to set android:label="#string/roster", which is incorrect.
The alternative is to completely hide the app name from all views. However, I struggled to do that and create the left image. I saw posts about using
android:theme="#android:style/Theme.NoTitleBar"
to remove titles, and I can do that, but then I couldn't display Roster in the red area. I can show more code on how my styles are set, if that is helpful.
Goal:
App name = Attendance Tracker
On Screen Activity = MainActivity (Roster is title)
On view of Roster activity, app name is hidden, Roster is shown in toolbar
On expanded view, app name is displayed as Attendance Tracker
AndroidMainfest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<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=".list_items"
android:label="#string/title_activity_list_items"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity android:name=".AddMember"
android:label="#string/roster_add">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DisplayMember">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Edit: I am aware the right picture displays different content, but the title bar is what I am focused on. I did not want to change the code of another page.

Simply calling the following method will hide the title from the toolbar
Assuming you're using the support library:
getSupportActionBar().setDisplayShowTitleEnabled(false);
Assuming you're using the system-provided toolbar:
getActionBar().setDisplayShowTitleEnabled(false);

Try this!!!
<activity android:name=".MainActivity"
android:label="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Related

android search view on another Activity

I'm Creating a Search View Sample Project;
I have 3 Activities:
MainActivity(Direct you to search Activity)
SearchActivity(You can see search View and type whatever you want)
SearchResultActivity(Will Process your Search request)
and in Manifest file I have
<activity
android:name="com.example.searchsample.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=".SearchActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<activity android:name=".SearchResultActivity">
</activity>
if I press search button; I can see the new SearchActivity Opens ;
if I move the intent-filter Part from .SearchActivity to .SearchResultActivity; I no longer can Search anything; (Because the .SearchResultActivity never run)
how can I solve this Problem;
I want, when I Press the search button, see result on .SearchResultActivity

Android: first activity after background

I get a problem when I running a app and the app goes to background. If I click on app icon again It shows activity mark as LAUNCHER:
<activity android:name=".LoginScreen" android:label="#string/app_name"
android:theme="#style/defaultStyle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But I want to show last activity active before background. It is something wrong on my AndroidManifest?
write android:launchMode="singleTask" in the manifest

App launcher to reload from beginning in Android

I have created app to act like an home launcher. So when user clicks on the home button I get Complete action using Launcher or my app's name say for example "myhomelauncher".
When I click on home button and click myhomelauncher my application loads everything from first perfectly fine. Now when I am in the second screen in my application say I am looking at activity 2 in my app and now I click on Home button and click myhomelauncher I endup getting the same activity 2 windows it is not reloading. (It should reload and show up activity 1 rather than 2)
I have seen lot of apps that can reload everytime I click their launcher. Why not mine?
Here is what I have done in my manifest.xml
<activity
android:name=".MyLauncher"
android:label="#string/app_name"
android:persistent="true"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I am not sure where is the mistake?
Please have a look into the documentation - what can be of interest to your problem are the following settings:
android:clearTaskOnLaunch
android:launchMode
I would suspect setting android:launchMode to singleTask could solve your problem, altough be careful which side effects this will cause.
So:
<activity
android:name=".MyLauncher"
android:label="#string/app_name"
android:persistent="true"
android:screenOrientation="landscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
should do the trick.
Look up launchMode. But be careful, with great power, comes great responsibility.
This is the relevant section in a menifest that seems to work for me. Note that I have put singleInstance in the launch mode because I don't want more than one of my app, ever.
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".usbEffects"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="portrait"
android:launchMode="singleInstance"
android:configChanges="keyboardHidden|orientation"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

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

One application installed, show two entries in launcher

In Android, how to implement the following effect?
Install just one application, but in the launcher, there are two entries, and entering each will go to different ui.
Just like google map, you can see only one application, but there are map and navigation entries.
Thanks.
You need to add category as android.intent.category.LAUNCHER for both of the activities in AndroidManifest.xml
Example:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MyActivity1" android:label="#string/app_name">
<intent-filter>
....
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MyActivity2" android:label="#string/app_name">
<intent-filter>
....
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Categories

Resources