pathsense / pathsense-samples-android

Sample Applications for the PathSense SDK
Other
26 stars 10 forks source link

Does not work for the locked device? #1

Closed zazor1911 closed 8 years ago

zazor1911 commented 8 years ago

Hello! I'm trying to get intent with Broadcast Receiver after the launch of the service, and lock the device, but I get it only when my screen is unlocked. Can help me please?

dyerjo commented 8 years ago

Which API are you trying to use?

On Mar 24, 2016, at 2:58 PM, zazor1911 notifications@github.com wrote:

Hello! I'm trying to get intent with Broadcast Receiver after the launch of the service, and lock the device, but I get it only when my screen is unlocked. Can help me please?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1

zazor1911 commented 8 years ago

Activity API

dyerjo commented 8 years ago

You have to register the receiver in the AndroidManifest.xml. You cannot programatically register the receiver.

On Mar 24, 2016, at 3:14 PM, zazor1911 notifications@github.com wrote:

Activity API

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201047176

zazor1911 commented 8 years ago

Yes, I register receiver like example: <receiver android:name=".PathsenseActivityUpdateBroadcastReceiver" />

dyerjo commented 8 years ago

Can you send me the code so I can look at it?

On Mar 24, 2016, at 3:21 PM, zazor1911 notifications@github.com wrote:

Yes, I register receiver like example: android:name=".PathsenseActivityUpdateBroadcastReceiver" />

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201050270

zazor1911 commented 8 years ago

What part of the code? I've done every step of this example: https://github.com/pathsense/pathsense-samples-android/blob/master/pathsense-activitydemo-app/README.md

dyerjo commented 8 years ago

It should be working then, in the background or foreground.

What version of Android are you running. Also, what device?

On Mar 24, 2016, at 3:32 PM, zazor1911 notifications@github.com wrote:

What part of the code? I've done every step of this example: https://github.com/pathsense/pathsense-samples-android/blob/master/pathsense-activitydemo-app/README.md https://github.com/pathsense/pathsense-samples-android/blob/master/pathsense-activitydemo-app/README.md — You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201057700

zazor1911 commented 8 years ago

I tried Samsung galaxy S3, Samsung galaxy S5, Lenovo P780, Sony z3, Android versions 4.4, 4.3 , 5.0, 5.1

zazor1911 commented 8 years ago

Maybe this is due to lack of resources. So there was a problem on the foreground. Broadcasts stop coming after a while time. Although simple in backgrounds it works.

dyerjo commented 8 years ago

No, that is not the issue.

Actually, I know what it is. The demo/sample app is intended to display the results on the screen and run in the foreground. If you go into the MainActivity, you will see the unregistering from the api in the onPause.

If you want it to run in the background, comment out the onPause method. Then it will run indefinitely while the process is alive.

On Mar 24, 2016, at 3:46 PM, zazor1911 notifications@github.com wrote:

Maybe this is due to lack of resources. So there was a problem on the foreground. Broadskast stop coming after a while time. Although simple in backgrounds it works.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201061540

zazor1911 commented 8 years ago

Yes, I see. But I do not use unregister. I only register broadcast receiver in my main activity.
Like:
api = PathsenseLocationProviderApi.getInstance(this); api.requestActivityUpdates(PathsenseActivityUpdateBroadcastReceiver.class);

dyerjo commented 8 years ago

Can you zip up the entire source and android manifest. I can take a look at it. It should work on the devices and OS you specified.

On Mar 24, 2016, at 3:55 PM, zazor1911 notifications@github.com wrote:

Yes, I see. But I do not use unregister. I only register broadcast receiver in my main activity.

Like:

api = PathsenseLocationProviderApi.getInstance(getApplicationContext()); api.requestActivityUpdates(PathsenseActivityUpdateBroadcastReceiver.class);

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201064465

zazor1911 commented 8 years ago

I'm sorry I can not do it. But that is my Verbose logs which contains "pathsense", they coming than device is locked too. http://pastebin.com/RUB3GE8K

dyerjo commented 8 years ago

Are you using the latest version? 2.0.0.0?

On Mar 24, 2016, at 3:59 PM, John Dyer john@pathsense.com wrote:

Can you zip up the entire source and android manifest. I can take a look at it. It should work on the devices and OS you specified.

On Mar 24, 2016, at 3:55 PM, zazor1911 <notifications@github.com mailto:notifications@github.com> wrote:

Yes, I see. But I do not use unregister. I only register broadcast receiver in my main activity.

Like:

api = PathsenseLocationProviderApi.getInstance(getApplicationContext()); api.requestActivityUpdates(PathsenseActivityUpdateBroadcastReceiver.class);

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201064465

zazor1911 commented 8 years ago

No, I using 1.0.0.2 version, cause him values is better for us. Last version give fail positive confidence for IN_VEHICLE when I was sitting at the table.

dyerjo commented 8 years ago

Can you switch to 2.0.0.0 just to test the same scenario and see if background works? It uses considerably less resources as 1.0.0.2.

On Mar 24, 2016, at 4:40 PM, John Dyer john@pathsense.com wrote:

Are you using the latest version? 2.0.0.0?

On Mar 24, 2016, at 3:59 PM, John Dyer <john@pathsense.com mailto:john@pathsense.com> wrote:

Can you zip up the entire source and android manifest. I can take a look at it. It should work on the devices and OS you specified.

On Mar 24, 2016, at 3:55 PM, zazor1911 <notifications@github.com mailto:notifications@github.com> wrote:

Yes, I see. But I do not use unregister. I only register broadcast receiver in my main activity.

Like:

api = PathsenseLocationProviderApi.getInstance(getApplicationContext()); api.requestActivityUpdates(PathsenseActivityUpdateBroadcastReceiver.class);

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201064465

zazor1911 commented 8 years ago

I tried to change, did not help. http://pastebin.com/tvJaVCS0

pablobaxter commented 8 years ago

@zazor1911 Just out of curiosity, when do you call api.removeActivityUpdates() in your code?

zazor1911 commented 8 years ago

That remove activity updates api.removeActivityUpdates()

dyerjo commented 8 years ago

That will remove the activity updates. Are you calling this in your MainActivity?

On Mar 24, 2016, at 5:34 PM, zazor1911 notifications@github.com wrote:

That remove activity updates api.removeActivityUpdates()

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201085388

zazor1911 commented 8 years ago

And I tried that

            if (Intent.ACTION_SCREEN_OFF.equals(action)) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        api.removeActivityUpdates();
                        api.requestActivityUpdates(PathsenseActivityUpdateBroadcastReceiver.class);
                    }
                };

                new Handler().postDelayed(runnable, 5000);

            }
zazor1911 commented 8 years ago

@dyerjo Yes, and that remove them

dyerjo commented 8 years ago

For now, comment out all references to api.removeActivityUpdates().

Once, you call api.requestActivityUpdates it will stay registered until you call remove. If you want the updates in the background, you do not need to do anything else.

On Mar 24, 2016, at 5:36 PM, zazor1911 notifications@github.com wrote:

And I tried that

        if (Intent.ACTION_SCREEN_OFF.equals(action)) {
            Runnable runnable = new Runnable() {
                public void run() {
                    api.removeActivityUpdates();
                    api.requestActivityUpdates(PathsenseActivityUpdateBroadcastReceiver.class);
                }
            };

            new Handler().postDelayed(runnable, 5000);

        }

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/1#issuecomment-201085606

zazor1911 commented 8 years ago

Yes, it was before, I did not use the removal. In my opinion the service is running after device is locked too, but broadcast receiver not called. I also checked his work this way from locked device:

    private String isServiceActiv(Context context) {
        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (service.service.getClassName().toLowerCase().contains("pathsense")) {
                return service.service.getClassName();
            }
        }
        return null;
pablobaxter commented 8 years ago

@zazor1911 Can you please email me at pablo@pathsense.com so we can dig deeper into this issue. Thanks!

zazor1911 commented 8 years ago

Thanks!