Subscription preference

Notification emails are sent to your Samsung account email address.

* Email : anonymous@samsung.com

  

Close

Android Sleep Time

Forums View
Started by Newbie ansh**** , 140 Seed Apr 18, 2017 07:58 Replies : 5 View : 284735 Likes : 0
Here , I want to know thta why I'm getting issue while fetching sleep hours. The error is:

 java.lang.IllegalArgumentException - Not permitted property (com.samsung.health.sleep) is used

I'm trying same way as we got steps count by mentioning in manifest and activity and a reported class but I'm not getting sleep hours. The sleep count reporter class as:


Code

 
public class SleepCountReporter {

    private final HealthDataStore mStore;
    private final HealthResultHolder.ResultListener<HealthDataResolver.ReadResult> mListener = new HealthResultHolder.ResultListener<HealthDataResolver.ReadResult>() {
        @Override
        public void onResult(HealthDataResolver.ReadResult result) {
            int count = 0;
            Cursor c = null;

            try {
                c = result.getResultCursor();
                if (c != null) {
                    while (c.moveToNext()) {
                        count += c.getInt(c.getColumnIndex(HealthConstants.Sleep.HEALTH_DATA_TYPE));
                    }
                }
            } finally {
                if (c != null) {
                    c.close();
                }
            }
            MainActivity.getInstance().drawSleepCount(String.valueOf(count));
        }
    };
    private final HealthDataObserver mObserver = new HealthDataObserver(null) {

        // Update the sleep count when a change event is received
        @Override
        public void onChange(String dataTypeName) {
            Log.d(MainActivity.TAG, "Observer receives a data changed event");
            readTodaysleepCount();
        }
    };

    public SleepCountReporter(HealthDataStore store) {
        mStore = store;
    }

    public void start() {
        // Register an observer to listen changes of sleep count and get today sleep count
        HealthDataObserver.addObserver(mStore, HealthConstants.Sleep.HEALTH_DATA_TYPE, mObserver);
        readTodaysleepCount();
    }

    // Read the today's sleep count on demand
    private void readTodaysleepCount() {
        HealthDataResolver resolver = new HealthDataResolver(mStore, null);

        // Set time range from start time of today to the current time
        long startTime = getStartTimeOfToday();
        long endTime = System.currentTimeMillis();
        HealthDataResolver.Filter filter = HealthDataResolver.Filter.and(HealthDataResolver.Filter.greaterThanEquals(HealthConstants.Sleep.START_TIME, startTime),
                HealthDataResolver.Filter.lessThanEquals(HealthConstants.Sleep.START_TIME, endTime));

        HealthDataResolver.ReadRequest request = new HealthDataResolver.ReadRequest.Builder()
                .setDataType(HealthConstants.Sleep.HEALTH_DATA_TYPE)
                .setProperties(new String[]{HealthConstants.Sleep.HEALTH_DATA_TYPE})
                .setFilter(filter)
                .build();

        try {
            resolver.read(request).setResultListener(mListener);
        } catch (Exception e) {
            Log.e(MainActivity.TAG, e.getClass().getName() + " - " + e.getMessage());
            Log.e(MainActivity.TAG, "Getting sleep count fails.");
        }
    }

    private long getStartTimeOfToday() {
        Calendar today = Calendar.getInstance();

        today.set(Calendar.HOUR_OF_DAY, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);

        return today.getTimeInMillis();
    }

}


 Can anyone please look at it and help me to resolve the issue ?

Tags

AndroidSDK

Post Reply
Board View
Newbie roger.ka**** , 320 Seed Jan 13, 2018 13:44 Post #1 0
Typically, from what i've read about what seems to be your problem, this issue only happens on Samsung phones with android 7.0. Now, assuming you're dealing with an Android problem, you can try to see if this replicates on Android 7.1.2 available in Samsung's Developers Remote Test lab here http://developer.samsung.com/remotetestlab/rtlDeviceList.action# 
You may also want to see if this problem discussed on SO is pertinent to you https://stackoverflow.com/questions/30703845/exception-on-serialization-on-samsung-galaxy-s5
But you'd have to provide more context into your problem in order to get better feedback and help? Can you elaborate a bit?

Post Reply
Board View
Newbie hakanl**** , 320 Seed Nov 13, 2018 07:26 Post #2 0
"Java.lang.IllegalArgumentException"
do you only get this error in sleep mode ? Can you share some more information? agario
Post Reply
Board View
Newbie pete11 , 210 Seed Apr 06, 2019 16:50 Post #3 0


This content has been quoted from hakanl****’s thought.

"Java.lang.IllegalArgumentException"
do you only get this error in sleep mode Can you share some more information?


Cyberflix apk https://cyberflixtvappdownload.com/cyberflix-tv-apk-download/is also a great app for samsung devices.

Post Reply
Board View
Newbie Catysuns , 330 Seed Apr 09, 2019 14:32 Post #4 0
 you about the vehicle's health and this shows the tire condition while picking up a Mon exchange your gun twice to get additional ammo already loaded in the rifle you can trap your opponent in the cave by blocking the entrance with a jeep and blast it one of the best ways to get the weapon master badge is to jump at the end of the map you'll see many offline players who could be killed easily in case of quick evacuation you can carry three members on a buggy in this manner keep in mind to drive slowly you can climb the roof of most of the houses in this manner here's a fun tip you can use a stun grenade to distract your teammates from looting a crate or a drop here's a bonus tip subscribe to clash universe for more such videos let's keep a light game of ten-thousands hope you guys do it .
Post Reply
Board View
Newbie neha6126 , 210 Seed Apr 17, 2019 15:25 Post #5 0


This content has been quoted from Catysuns’s thought.

 you about the vehicle’s health and this shows the tire condition while picking up a Mon exchange your gun twice to get additional ammo already loaded in the rifle you can trap your opponent in the cave by blocking the entrance with a jeep and blast it one of the best ways to get the weapon master badge is to jump at the end of the map you’ll see many offline players who could be killed easily in case of quick evacuation you can carry three members on a buggy in this manner keep in mind to drive slowly you can climb the roof of most of the houses in this manner here’s a fun tip you can use a stun grenade to distract your teammates from looting a crate or a drop here’s a bonus tip subscribe to clash universe for more such videos let’s keep a light game of ten-thousands hope you guys do it .

<a href="http://whatscr.com">http://whatscr.com"</a>

Post Reply