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

How to get value distance on background process since service will stop in background process #4

Open
hafiz013 opened this issue Jul 23, 2019 · 2 comments

Comments

@hafiz013
Copy link

private void onNewLocation(Location location) {
Log.d(TAG, "New location: " + location);

    mLocation = location;

    // Notify anyone listening for broadcasts about the new location.
    Intent intent = new Intent(ACTION_BROADCAST);
    intent.putExtra(EXTRA_LOCATION, location);
    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);

    // Update notification content if running as a foreground service.
    if (serviceIsRunningInForeground(this)) {
        mNotificationManager.notify(NOTIFICATION_ID, getNotification());

        // Getting location when notification was call.
        latitude = location.getLatitude();
        longitude = location.getLongitude();

        // Here using to call Save to serverMethod
        SavetoServer();

    }
}

could u explain how to get value when the apps in background process?

@BlackBlind567
Copy link
Owner

In if condition is checking your app is in foreground or background after that it runs a method.

@hafiz013
Copy link
Author

hafiz013 commented Aug 8, 2019

@BlackBlind567 hi do u know how to check this service already run regardless background or foreground in main activity?

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