How to get android device activites without using “Google fit” - android

Is there any way to get activities done by user from Android device like active time, inactive time, cyclic distance, steps count etc. without using “Google fit” api like M9 chip does in iPhone devices.

Somehow i found to get device activity by help of "Google APIs for Android" .Here you cannot get the proper count but can get the device activation mode.Please see below link
[https://developers.google.com/android/reference/com/google/android/gms/location/DetectedActivity]

Related

Flutter: How can i extract a specific value out of the Huawei Settings App?

If I am charging my Huawei Phone and go to Settings --> Battery there is at the Top a Value, that shows how mach time my Phone needs until it is fully charged. My Question now is, if there is a way to extract this value with Flutter and use it in my App?The Battery value
Try to use battery_level package for get information about a device battery state.
Yes you can get the battery level from a huawei phone. Use this package: https://pub.dev/packages/battery. It will help grab the battery level information and allow you to use and manipulate it in flutter.
I tested this on honor v30 and it works fine.

How to prevent phone from going to idle mode

I've developed an application that streams music (via internet connection) using service and having trubles streaming content without phone going idle.
While i was developing my application each time i tried case mentioned below the music was reproducing fine.
Use case : search song, select song from results, play song, screen off -> auto play next song from result list
I'm developing using real device - Huawei Mate 20 Lite - OS v8.01 so while debugging it gotta use USB cabel.
Like i said following the use case above while hooked on USB the auto play while screen off works good. The case it doesn't work good is when the cable is not connected (only mobile data turned on).
What I've figured out is that phone when connected on USB is probably keeping the device awake and it doesn't go to idle mode while when not connected after around 5mins the device probably shuts down processes that cost energy or it shuts down connection to mobile data i'm not sure and there's where i need you guys.
Also I've tested app using HTC U Play - OS v6.0 and the streaming goes smooth without interrupts while screen off and phone wasn't touched for 10+mins.
Also I've tried to acquire wakelock inside oncreate and without releasing it just to see if it helps and it doesn't.
pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wl.acquire();
This problem you are facing can be due to the fact that after Andriod 6.0, all apps are getting optimized for optimizing the battery usage.
If you really think, the reason behind the application to go killed is inactivity. Then, probably, its because of battery optimization software itself.
You can enable another permission while installing the app on the device where you can update the list of unoptimized app by adding an entry for your app.
Originally, you will be able to do the manual settings by following below instruction.
. Head for the ‘Settings‘ app and then ‘Battery‘
. On the ‘three dots‘ menu, top right, you’ll find ‘Battery optimisation‘.
. Here you’ll see a list of all applications which shouldn’t be ‘optimised‘ (for which read ‘can be handled by Doze and App Standby’) – by default the list is usually very small, with almost all apps enabled for ‘optimisation’. Which is fine for general users, but if, like me, you want a few applications to live outside of the new battery optimisations, then tap on the ‘Not optimised‘ pick list and choose ‘All apps‘
. As you’d expect, every application on your phone is listed (this may be quite long) – swipe down until you find the application(s) that you particularly want to always keep running. Tap on the application name
. From the two choices, check the box for ‘Don’t optimise‘.

Not able to get Local Notification when app is not in background in Android

I have prepared demo to receive local notification daily like alarm, but its working in some device and not working in some other device (Like OPPO, MI) when app is not in background not receiving notification.
Can any one please help to provide source code or any reference link to resolve this issue.
Mostly notification working on some devices because of two reasons:
1) If device API level is 6.0+
2) Account Sync not working.
1) If device API level is 6.0+ then you need to write permission handler code Example
2)Account Sync not working. go to settings > then select Google account > and click on Sync button. If on Google account it showing ! this symbol then that means problem is in your device account sync.

Cannot set temperature interval on sensortag

I'm creating an android application that interfaces with the texas instruments sensortag. One of the things the app needs to do is be able to change the frequency in which the temperature is reported to the app. I am able to change it through the official TI app which is great, but I cannot seem to get it working in my app.
When viewing the official app (iOS, can't run the android one?), it shows the temperature GATT service, which contains 3 characteristics. When I inspect the characteristics discovered by my app however, it only seems to find two - the data, and the notifications. Not the interval. I have attempted to construct this characteristic myself and write it however it doesn't do anything - no error, no success, just nothing.
The steps I've taken are essentially:
bluetoothGatt.discoverServices();
...
services = bluetoothGatt.getServices();
...
BluetoothGattService service = bluetoothGatt.getService(serviceUUID);
System.out.println("Characteristic = " + service.getCharacteristic(SensorTagGatt.UUID_IRT_PERI));
The output yields null. Is there something obvious I'm missing or that I should be doing that I might not be?
EDIT:
I've installed another app onto the phone written by another developer, and using this to inspect the services and characteristics available shows that it too is unable to find it, so I'm assuming there is something wrong with the android service discovery? The official iOS app is working as expected, and showing all characteristics. Unfortunately, the official android app seems to be incompatible with the version 1.5 firmware and crashes when trying to connect but I assume it too will fail to find the characteristic.
Has anyone else run into this issue and if so been able to get around it?

Unable to simulate location data in Android emulator

I'm trying to test my app, which uses geolocation using the emulator. Several methods are described here. I'm going to Window->Open Perspective->DDMS, then entering lat. and long. one in Location Controls and then I hit "Send".
But it doesn't work. Instead I see the following error: Unable to send command to the emulator.
Why is this happening!?
I don't think my app is the problem because I tested with the emulator's default browser and it also cannot access location info.
Details:
OSX 10.9.4
AVD_for_Nexus_4_by_Google targeting v4.4.2
Eclipse IDE for Android Developers 23.0.2.1259578
Update:
I changed to AVD_for_Galaxy_Nexus_by_Google and it still doesn't work, but I no longer see that error. I click send and nothing happens.
Update2:
I've tested using Telnet to pass location data to the emulator, and again nothing happens. No errors. Just nothing. Urgh!
telnet localhost 5554
geo fix 50 50
It responds with OK but nothing happens. Still no location data available.
Update3:
I notice a stream of the following errors in LogCat
09-20 17:58:59.910: E/eglCodecCommon(1777): glUtilsParamSize: unknow param 0x00000b44
09-20 17:58:59.910: E/eglCodecCommon(1777): glUtilsParamSize: unknow param 0x00000bd0
09-20 17:58:59.930: E/eglCodecCommon(1777): **** ERROR unknown type 0x0 (glSizeof,72)
The app seems to be running fine, and these errors are supposedly explained here.
Update 4:
I've seen multiple suggestions to confirm that my AVD has GPS Support enabled, but this option/setting does not appear anywhere. When I open the "Android Virtual Device Manager" and then click "Edit" on one of my devices, this is what I see:
No mention of "GPS Support".
Update 5:
I checked the config.ini file for all my AVDs and they are all correctly set to hw.gps=yes. I also created an AVD using a Google API target, however I'm still having the same problem. The app loads but no location data is available, with "Location Controls" as well as telnet.
Update 6:
Following Gyebro's suggestions below... trying to load his LocationDemo app...
Here's what I see in the LogCat:
To check whether your emulator supports GPS, go to ~/.android/avd/<emulatorname>.avd/ and check config.ini and hardware-qemu.ini (if exists) they should contain:
hw.gps = yes
EDIT
You must use a Google APIs system image. You should set Google APIs - API Level 1# as target
End of EDIT
Assuming this is so, and Location is enabled in your emulator, run this test application in your emulator: LocationTest demo, for details see the Dev docs on Retrieving the Current Location
This sample implements GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener and LocationListener. And also checks for Google Play Services before connecting with the LocationClient (that's why we needed a Google Emulator image.) (See MainActivity.java)
After you start the app, you should see the Location icon in the status bar. Also verify, that the GP Services are present and the LocationClient is connected in the Log.
D/LocationTest﹕ Google Play services is available.
D/LocationTest﹕ LocationClient: Connected
After sending geo fix 66 80 using telnet (should respond with OK) or other valid coordinates using DDMS, you should see:
D/LocationTest﹕ Location changed!
If you are still lost with this approach, another way to simulate locations is to create a Mock Location Provider app.
You really should use GENYMOTION it offers a GPS feature in which u set the location coordinates, plus it's faster than the default emulator and works fine in almost every OS, heres the Docus on how to apply that GPS stuff here inside that page look for "GPS widget". Good luck.
Heres a shot from that window
I tried with latest SDK and adb tools, i see the same problem with Google Maps and web browser based location (maps.google.com). I used adb command line as well as telnet methods to set the location. Also verified my .avd file has hw.gps=yes (which is set by default). I even tried with older Google API images. I made sure to try out different accuracy levels too - device only, high accuracy etc. I notice lot of graphics rendering issues and quite a few opengl error messages in logcat, similar to ones you see.
I did get google maps app to work on Android emulator using mock locations feature. You can use mock locations on a real device too, which i prefer for its performance. For details on how to use mock location please see this.. Download the zip file which has LocationProvider project , that lets you simulate different location and movement scenarios.
so you can pick:
Use a physical android device with mock locations feature
If you want to use emulator, try with mock locations
I had success with genymotion too, you can set any location you want from command line genyshell that comes with genymotion
genyshell.exe -c "gps setstatus enabled"
genyshell.exe -c "gps setlatitude 30.3077609"
genyshell.exe -c "gps setlongitude -97.7534014"
device is preferable for performance reasons.
Update:
I tested with LocationTest demo by gyebro and it works when i set the location params using telnet. So the problem seems to be with google maps or browser and not with emulator or adb tools.
Did you tried with free version of Genymotion? It works as a real device connected by USB, and it can create GPS positions as you need. I know that this is not a solution for your AVD problem but AVD is in generally a poor solution to Android testing on emulators.
It's free if you want to test this function specifically.
I was running through the same errors. The problem was that the AVD DDMS uses a comma instead of a dot in their location coordinates.
Use LAT: -16,691534 LNG: -49,266185 something like this and you will be fine!

Categories

Resources