Skip to content

Commit

Permalink
add error handling for null pointer exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jask1m committed Nov 22, 2024
1 parent 9dbf7ad commit 38cb50f
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ public class UsbFragment extends Fragment {
public View onCreateView(
@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.usb_fragment, container, false);
bundleTransmission = ((BundleClientActivity) getActivity()).wifiBgService.getBundleTransmission();
BundleClientActivity activity = (BundleClientActivity) getActivity();
if (activity != null && activity.wifiBgService != null) {
try {
bundleTransmission = activity.wifiBgService.getBundleTransmission();
} catch (Exception e) {
logger.log(Level.WARNING, "Error getting bundle transmission: ", e);
}
} else {
logger.log(Level.INFO, "BundleClientActivity or wifiBgService is null");
}

usbExchangeButton = view.findViewById(R.id.usb_exchange_button);
usbConnectionText = view.findViewById(R.id.usbconnection_response_text);
Expand Down

0 comments on commit 38cb50f

Please sign in to comment.