How to go about detecting data usage in the Android environment - android

I would like to be able to detect all forms of data usage using the Android environment. Is it possible to keep tabs on which applications call on say RTP vs WAP, etc. such that I can know at all times when data is being used by a native program or third-party app?

If you are talking about an Android API to monitor network statistics by application then such an API seems to have been added in Android 2.2 (Froyo).
The main class you'll need is TrafficStats.
You can use getUid{Rx|Tx}Bytes(int uid) for the given process user ID (which you can get from ActivityManager.getRunningAppProcesses()).
The API is very simple and simply gives you the total bytes received/sent, so you'll have to do some more work to keep track of hourly, daily, and monthly stats. Well, that all depends on your needs.
I haven't tried using it myself, so I cannot give you any more detail, nor do I know the supported devices (not all devices will support this as the API points out).

Related

Is the API for exercise machines (like NordicTrack iFit) open? Can I write an app to control my bluetooth-enabled machine?

I've written standalone apps that construct workouts that I can build to vary time, resistance, etc., but they don't communicate with a dedicated exercise machine. I recently bought a NordicTrack elliptical machine which uses their iFit framework (using their iFit Bluetooth app) to control the machine's resistance and incline. Is this an open Bluetooth-accessible API that I can access to have my app connect to the machine and manipulate the resistance and incline myself? Anyone?
It's not open because the companies (ProForm, NordicTrack) want to earn extra money besides the one time purchase price through constantly flowing subscription money via the iFit service. They need to somehow make it an exclusive option to use iFit, otherwise they'd lose another cash cow, I'd even say maybe the constant subscription flow is more important than the MSRP.
On fitness forums (like slowtwitch forum https://forum.slowtwitch.com/forum/Slowtwitch_Forums_C1/Triathlon_Forum_F1/Treadmill_iFit_%22hack%22_/_tweak_P6851409/) people were figuring out how to get into admin mode and access the Android tablet as it is. Lately Nordictrack moved and tries to block the users from accessing privileged mode condescendingly in the name of safety: https://www.extremetech.com/extreme/329275-owners-resort-to-hacking-smart-treadmills-after-nordictrack-locks-them-out. This is similar what Peloton pulled: https://www.makeuseof.com/peloton-treadmills-lose-free-just-run/
However when communication happens with apps there always be a possibility to reverse engineer protocols, although that's tedious and sometimes result in fragile code, and condescending companies could always push updates which intentionally interfere with hack solutions.
According to forums the https://github.com/belden/iFitController web protocol based solution (mentioned by #papahouss, I found another repo which exists) only works with 2017 and earlier devices. The later models switched to Bluetooth (it sounds like you have such machine) so the HTTP project won't work for you most probably.
There are a few projects trying to integrate iFit devices with Zwift, and some other extra projects. This one particularly looks very promising, but I haven't got to study it in details yet: https://github.com/dawsontoth/zwifit/blob/master/src/ble/ifit/_request.js
Maybe you should have a look at this project : https://github.com/jamesdotcuff/iFitController
You can communicate with the machine via websock. It works for treadmill but not too sure about elliptical machine.
Good luck

Android, List events from specific calendar (on Phone (?))

I want to show a ListView with the events of the current day from a specific calendar. The calendar is originally fetched from a .ical file and synchronized into my google account. And yes, I've searched.
Should I go with the content:// stuff?
Im using Android 2.2 and above.
One option would be to use the Google Calendar API functions. On the surface it seems like tons of work, however you are mostly importing (Build Path) their jar files and making the appropriate imports and method calls.
http://code.google.com/apis/calendar/v3/getting_started.html
This turns into HTTP requests and the like, which implies you must always be connected to the network (I'm not a fan of that).
Officially supported or not, I am working on an application that is working with the local phone calendar database and doing what I need to do there (yes, the content:// URI stuff you mentioned above).
Either way, you can do what you are needing to do as your application seems simple enough. Most people, and rightfully so, will tell you to use the Google Calendar API imports/calls because it is supported functionality that does not rely on how the device manufacturer chose to implement the back end content provider. Although every phone I have tested uses "content://com.android.calendar/events" as the URI, that does not mean that it will always work as that can change (and has in the past) based on the version of Android running on the device.
Android 2.1 and before: content://calendar/calendars
Android 2.2 - 2.3: content://com.android.calendar/calendars

Network traffic monitoring per android application

I was wondering if I can do network traffic monitoring per android application?
Basically see which app is receiving/sending how much data?
I know there are many apps which already do that but I want to know how to do it.
Well you surely can. A very simple way is to use the TrafficStats class. It can manage per app (more formally, per UID) But the problem is, it can return UNSUPPORTED. When this happens, I don't think you will have some easy (i.e. using the high level Java language) method to get the network traffic data you need.
Not sure if it can be implemented in Java as I imagine you need to access some low-level Operating system functions which are just not available in Java (but don't quote me on this!).
The obvious way I see of doing this is through C language and the Android Native Development Kit.

Change the Network Operator with an Android App

I'm trying to develop an Android App which shows the signal strength of various network operators on a map. The problem is that the only way to change the network operator is by doing it by hand.
Any ideas on how I can get this information without changing it manually? I think that there are internal/private Android classes to do this.
You will need to use one or more of Google's internal APIs to do this. They are not, by default, available to Android applications for various (usually good) reasons. The API for turning tethering on and off and configuring it, for example, is not a public API and cannot be invoked directly by third party applications.
You will need to do two things. First, download the Android source code and find the API(s) you need to list and switch carrier. You can find the Android source code, and download instructions, here.
Second, you will need to use reflection to invoke the methods on those APIs. The best approach to this, and one I used myself to play with the tethering API, is to write a proxy class. Give it all the same methods as the API you want to use, and inside each method use reflection to invoke the API method. Any other technique will either (a) not compile without adding portions of the Android source code to your classpath and then (b) will compile but blow up when you deploy.
Be aware that you're best doing this on a Nexus branded device as this has the vanilla Android code on it. My (successful) attempt to write a home screen widget to turn tethering on and off worked on a Nexus One but did not work on a Samsung Galaxy Tab P1000. The device supported tethering, but Samsung had modified that part of the OS as part of their porting effort.

What are the key differences between Android, iOS and Blackberry OS?

What are the key differences between Android, iOS and Blackberry OS in terms of level of accessibility by application developers (i.e. access to the video input, sound input, phone functionalities, to which extent, etc.)?
PS: Assume latest version of each OS.
EDIT: Can someone turn this into a wiki so we can compile answers from people that don"t necessarily have experience in all 3 plaforms.
I'm not familiar with BlackBerry, but on Android and iOS you can access just about anything. Until recently iOS had some restrictions about camera access (see this), but I belive those have been solved. Because Android is open-source, you can theoretically go as deep as you want as far as accessing the hardware, but you may or may not be able to get any deeper through the standard Android API than you can through the iOS API.
On Android, you can do a lot more to override default functionality. For example, you can create your own launcher screen or phone application. The iOS approval process wouldn't allow these kinds of applications.
API hardware access really isn't an issue on either platform, the bigger concern is overriding default software (almost never possible in iOS) and what types of applications iOS allows.
Each platform has its own nice and bad parts. I have been working on both Android and BB. I wish I could take only nice parts from both to create a platform of a dev dream! :)
For instance, I could take these features from BB:
The greates feature I like in BB is the simplicity of the application architecture - you can always count on your main UIApplication instance - OS never kills it.
Also I do like the simplicity the Dialog class provides - it is very easy to implement business logic related to user choice - while Dialog screen is shown the code execution just stops and waits for user input.
From Android I'd take the following:
Network communication. On BB this is a real nightmare (BES, BIS, WIFI, Direct TCP without APN, Direct TCP with APN, WAP, WAP2, Unite - who's next? :)).
For file manipulations you just use a native/usual Java API.
Nice looking UI components are available right out of the box.
I should add I'm not happy with GPS related stuff on both platforms, however maybe it is due to GPS hardware limitations rather than API creators.
Thanks!
BlackBerry is a pain, once I made a project for it (the JDE version was 4.7 back then) and it didn't had an ArrayList. WTF?

Categories

Resources