Android 14 - mayurparmar2/AlarmDemo GitHub Wiki
-
logErrors.java
// Caused by: java.lang.SecurityException: com.demo.supercleaner: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts ContextCompat.registerReceiver(context,receiver, intentFilter, ContextCompat.RECEIVER_EXPORTED); // upgrade appcompat
-
Location.java
//define interface LocationServiceCallback { fun onLocationServicesEnabled() fun onLocationServicesDisabled() } //define fun checkLocationServices(context: Context, callback: LocationServiceCallback) { val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager val isGpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) val isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) if (!isGpsEnabled && !isNetworkEnabled) { // Location services are disabled callback.onLocationServicesDisabled() } else { // Location services are enabled callback.onLocationServicesEnabled() } } // call checkLocationServices(requireContext(), object : LocationServiceCallback { override fun onLocationServicesEnabled() { val intent = Intent(requireActivity(), OfflineMapActivity::class.java) intent.putExtra("map_type", "OFFLINE_MAPS") requireActivity().startActivity(intent) } override fun onLocationServicesDisabled() { val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS) requireContext().startActivity(intent) Toast.makeText(requireContext(),"Please allow Location permission",Toast.LENGTH_LONG).show() } })