Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Title/Label of an Activity in Android 5 recents screen

With Android 5, Google supports multiple activities in the recents screen for a single application. I managed to implement multiple activities in the recents screen with this official doc. How can I change the title of the activity? Switching to recents screen always shows my app name as title.

Activity.setTitle("title"); 

changes the title on the toolbar, but I want it to change in the recents screen, just like Google does in Google Chrome App.

I need to change the title programatically.

like image 440
Brian Avatar asked Mar 01 '15 18:03

Brian


People also ask

How to change the title text of an Android activity?

If you want to change the Title text for your Android Activity that is displayed on the ActionBar you can do it using Java code by using setTitle () method.

How do I change the title of an activity?

Add EditText and a Button in the layout file. We shall type the desired title in the EditText and click the button which would perform the title change operation. Go to the MainActivity.kt file and refer to the following code.

How to change Android title bar or toolbar text programmatically?

Change Android Title Bar or Toolbar or Action-Bar text Programmatically. Follow the below steps to create a Toolbar and change its title at runtime. Step 1: Create a new Android Project using the "Empty Activity" Template. Step 2: Add the below code to the " activity_main.xml " file manually. Even if you use com.google.android.material.appbar.

What is the application title in an Android application?

Whenever we develop an Android application and run it, we often observe that the application comes with an ActionBar with the name of the application in it. This happens by default unless explicitly changed. This text is called the title in the application.


1 Answers

In your activity you can use new method:

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.secondary_layout);
    setTaskDescription(new ActivityManager.TaskDescription("Activity 2"));
}

setTaskDescription sets information about activity in recents task list. In this example only title.

like image 79
Sol Avatar answered Sep 30 '22 15:09

Sol