primary-context-has-title

Ensure that top-level activity is labeled so screen reader users get the context about their location.

Who might be affected
Screen Reader

Description

The primary context refers to the view at the top of the screen's hierarchy. Titling the top-level view or activity provides screen reader users with the context of which screen they are currently on.

Quick Fixes

It is recommended to use Android's built-in title property in every top-level activity.

Android (.xml):

You can set the title of an activity in your AndroidManifest.xml file by using the android:label attribute:

1<activity android:name=".MainActivity"
2 android:label="My Activity Title">
3</activity>

Android (Java):

In Java, you can set the title in your Activity class:

1 public class MainActivity extends AppCompatActivity {
2
3 @Override
4 protected void onCreate(Bundle savedInstanceState) {
5 super.onCreate(savedInstanceState);
6 setContentView(R.layout.activity_main);
7 setTitle("My Activity Title");
8 }
9 }

How Users Are Affected

Screen reader users will find it hard to get the context of the page without reading or interpreting its content.

WCAG Success criteria

This issue might cause elements to fail one or more of the following Success criteria:
2.4.2 Page Titled (A)