mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Use non-deprecated resolveActivity method on API 33+
But such method is not available before API 33
This commit is contained in:
		| @@ -72,9 +72,16 @@ public final class ShareUtils { | |||||||
|     public static void openUrlInBrowser(@NonNull final Context context, final String url) { |     public static void openUrlInBrowser(@NonNull final Context context, final String url) { | ||||||
|         // Resolve using a generic http://, so we are sure to get a browser and not e.g. the yt app. |         // Resolve using a generic http://, so we are sure to get a browser and not e.g. the yt app. | ||||||
|         // Note that this requires the `http` schema to be added to `<queries>` in the manifest. |         // Note that this requires the `http` schema to be added to `<queries>` in the manifest. | ||||||
|         final ResolveInfo defaultBrowserInfo = context.getPackageManager().resolveActivity( |         final ResolveInfo defaultBrowserInfo; | ||||||
|                 new Intent(Intent.ACTION_VIEW, Uri.parse("http://")), |         final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://")); | ||||||
|                 PackageManager.MATCH_DEFAULT_ONLY); |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||||||
|  |             defaultBrowserInfo = context.getPackageManager().resolveActivity(browserIntent, | ||||||
|  |                     PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY)); | ||||||
|  |         } else { | ||||||
|  |             defaultBrowserInfo = context.getPackageManager().resolveActivity(browserIntent, | ||||||
|  |                     PackageManager.MATCH_DEFAULT_ONLY); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (defaultBrowserInfo == null) { |         if (defaultBrowserInfo == null) { | ||||||
|             // No app installed to open a web url |             // No app installed to open a web url | ||||||
|             Toast.makeText(context, R.string.no_app_to_open_intent, Toast.LENGTH_LONG).show(); |             Toast.makeText(context, R.string.no_app_to_open_intent, Toast.LENGTH_LONG).show(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stypox
					Stypox