mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	Merge pull request #142 from esensar/fix/shortcut-pin-crash
Do a check for shortcut host permissions before pinning a shortcut
This commit is contained in:
		| @@ -233,6 +233,7 @@ class MainActivity : SimpleActivity(), FlingListener { | |||||||
|             REQUEST_CREATE_SHORTCUT -> { |             REQUEST_CREATE_SHORTCUT -> { | ||||||
|                 if (resultCode == Activity.RESULT_OK && resultData != null) { |                 if (resultCode == Activity.RESULT_OK && resultData != null) { | ||||||
|                     val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps |                     val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps | ||||||
|  |                     if (launcherApps.hasShortcutHostPermission()) { | ||||||
|                         val item = launcherApps.getPinItemRequest(resultData) |                         val item = launcherApps.getPinItemRequest(resultData) | ||||||
|                         if (item.accept()) { |                         if (item.accept()) { | ||||||
|                             val shortcutId = item.shortcutInfo?.id!! |                             val shortcutId = item.shortcutInfo?.id!! | ||||||
| @@ -244,6 +245,7 @@ class MainActivity : SimpleActivity(), FlingListener { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     override fun onConfigurationChanged(newConfig: Configuration) { |     override fun onConfigurationChanged(newConfig: Configuration) { | ||||||
|         super.onConfigurationChanged(newConfig) |         super.onConfigurationChanged(newConfig) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user