Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is the "InternetUtils.java" class not used anywhere? How to check internet connectivity continuously? #1

Open
USisFounderOfISIS opened this issue Jun 16, 2023 · 3 comments

Comments

@USisFounderOfISIS
Copy link

InternetUtils.java

How to check internet connectivity continuously? using above class?

@simonesestito
Copy link
Owner

simonesestito commented Jun 16, 2023 via email

@USisFounderOfISIS
Copy link
Author

USisFounderOfISIS commented Jul 19, 2023

I forgot to tell you (sorry for this negative comment) why you used so many deprecated methods like onActivityResult, getTargetFragment(), getTargetRequestCode() , while you was aware of power of viewModel technique? (perhaps these methods weren't deprecated when you finished the project?)

It also contain other deprecated methods that I am worry about them: , onCreateOptionsMenu, onOptionsItemSelected, onRequestPermissionsResult, onActivityCreated. I've fixed some of them. for example, I've moved all methods inside onActivityCreated into onViewCreated and deleted all onActivityCreated parts. I've also fixed some none-working FCM methods (due to the FCM new update) and deprecated location methods.

        FirebaseInstanceId.getInstance().getInstanceId()
                .addOnSuccessListener(instanceIdResult -> {
                    String token = instanceIdResult.getToken();
                    fcmService.addFcmToken(new FcmToken(token));
                })
                .addOnFailureListener(Throwable::printStackTrace);

into

        FirebaseMessaging.getInstance().getToken()
                .addOnCompleteListener(new OnCompleteListener<String>() {
                    @Override
                    public void onComplete(@NonNull Task<String> task) {
                        if (!task.isSuccessful()) {
                            //Log.e(TAG, "Fetching FCM registration token failed", task.getException());
                            return;
                        } else {
                            fcmService.addFcmToken(new FcmToken(task.getResult()));
                        }
                    }
                });

AND this location code (in MapUtils, for deprecated reason)

LocationRequest locationRequest = LocationRequest.create()
                    .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                    .setInterval(5_000)
                    .setFastestInterval(3_000)
                    .setSmallestDisplacement(100);

into

LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000)
                    .setWaitForAccurateLocation(true)
                    .setMinUpdateIntervalMillis(100)
                    .setMaxUpdateDelayMillis(100)
                    .setMaxUpdates(1)
                    .build();

AND this

private static LocationRequest createLocationRequest() {
        return LocationRequest.create()
                .setNumUpdates(1)
                .setExpirationDuration(5_000)
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    }

Into

private static LocationRequest createLocationRequest() {
        return new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000)
                .setWaitForAccurateLocation(true)
                .setMinUpdateIntervalMillis(2000)
                .setMaxUpdateDelayMillis(100)
                .setMaxUpdates(1)
                .build();

Don't forget to update to last version of FCM.

@simonesestito
Copy link
Owner

Hi, as you can see from the README, this project has been made for my high school graduation exam, and I didn't have any motivation to update it since then (that's why you can find old FCM and libraries versions). In fact, last commits are 3 years old.

Also, it uses Java and not kotlin, while I knew it since then, because Java was the required programming language even if I highly prefer kotlin.

perhaps these methods weren't deprecated when you finished the project?

That's right! In fact, I really care about Android Studio warnings, and while these methods are reported as bad or not existent anymore, at that time it was completely fine on the latest stable release.

Legal Notice

I've fixed some of them

Remember that this project is licensed under the terms of the GPLv3 license, so any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.

You can look at the full license in the LICENSE.txt file or read the tldr at https://www.tldrlegal.com/license/gnu-general-public-license-v3-gpl-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants