android intent USES the definition title

  • 2020-05-07 20:23:46
  • OfStack

You can use the Intent.createChooser () method to create Intent and pass in the desired Sting as the title.

Take the wallpaper selection box as an example. When long pressed on the blank area of Launcher workspace, the selection box of wallpaper will pop up. The title of the selection box is "Choose wallpaper from", as follows:
 
private void startWallpaper() { 
showWorkspace(true); 
final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER); 
Intent chooser = Intent.createChooser(pickWallpaper, getText(R.string.chooser_wallpaper)); 
// NOTE: Adds a configure option to the chooser if the wallpaper supports it 
startActivityForResult(chooser, REQUEST_PICK_WALLPAPER); 
} 

Where, the corresponding string content of R.string.chooser_wallpaper is "Choose wallpaper from", which is defined in Strings.xml of Launcher2

Related articles: