Skip to content

Commit

Permalink
fixed Android 12 installation errors and crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliexdev committed Nov 12, 2021
1 parent fc02ea3 commit 77960dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
13 changes: 7 additions & 6 deletions android_app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,32 @@
<activity
android:name=".gui.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".gui.slides.AppIntroActivity" android:theme="@style/AppTheme.NoActionBar"/>
<activity android:name=".gui.slides.SlideToNavigationAdapter" android:theme="@style/AppTheme.NoActionBar"/>
<activity android:name=".gui.slides.AppIntroActivity" android:theme="@style/AppTheme.NoActionBar" android:exported="true"/>
<activity android:name=".gui.slides.SlideToNavigationAdapter" android:theme="@style/AppTheme.NoActionBar" android:exported="true"/>

<receiver android:name=".core.alarm.ReminderBootReceiver" android:enabled="false">
<receiver android:name=".core.alarm.ReminderBootReceiver" android:enabled="false" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>

<receiver android:name=".gui.widget.WidgetProvider">
<receiver android:name=".gui.widget.WidgetProvider" android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>

<activity android:name=".gui.widget.WidgetConfigure">
<activity android:name=".gui.widget.WidgetConfigure" android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void onResume() {
if (PermissionHelper.requestBluetoothPermission(this)) {
startBluetoothDiscovery();
}

super.onResume();
}

Expand Down Expand Up @@ -404,6 +405,13 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in
} else {
Timber.d("At least one Bluetooth permission was not granted");
Toast.makeText(requireContext(), R.string.permission_not_granted, Toast.LENGTH_SHORT).show();

if (getActivity().findViewById(R.id.nav_host_fragment) != null){
Navigation.findNavController(requireActivity(), R.id.nav_host_fragment).getPreviousBackStackEntry().getSavedStateHandle().set("update", true);
Navigation.findNavController(requireActivity(), R.id.nav_host_fragment).navigateUp();
} else {
getActivity().finish();
}
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,14 @@ public static boolean requestBluetoothPermission(final Fragment fragment) {
Timber.d("SDK >= 31 request for Bluetooth Scan and Bluetooth connect permissions");
requiredPermissions = new String[]{Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT};
fragment.requestPermissions(requiredPermissions, PERMISSIONS_REQUEST_ACCESS_BLUETOOTH);
return false;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && targetSdkVersion >= Build.VERSION_CODES.Q) {
Timber.d("SDK >= 29 request for Access fine location permission");
return requestLocationPermission(fragment, new String[]{Manifest.permission.ACCESS_FINE_LOCATION});
} else {
Timber.d("SDK < 29 request for coarse location permission");
return requestLocationPermission(fragment, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION});
}

return true;
}

private static boolean requestLocationPermission(final Fragment fragment, String[] requiredPermissions) {
Expand Down

0 comments on commit 77960dc

Please sign in to comment.