Network traffic monitoring per android application - android

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.

Related

Jetpack Compose and Wireless Direct

I know this is way too general, but I have a reason. I am looking forward to make a simple app that can transfer strings from my mobile device to my TV. I wish to transfer this data over Wi-Fi, provided that the TV and my phone are on the same network. Now, the Android Documentation for the P2P Wireless APIs is DEAD. It even uses some deprecated implementations, and to worsen that up, nobody cared to provide an up to date documentation for carrying it out in modern day programming.
All I want, is a reference to a reliable source that might be helpful in understanding this. I added the compose tag, again, so that the info is conveyed that the app is built using a declarative paradigm, unlike the traditional android system. The sources may still be using the old android system (I, however, would prefer a Compose app). If nothing, at least point me to the correct (and updated) documentation, if it at all exists.

Can one access Android API in a Java Application outside Android?

I want to access Android API classes outside an Android project. For example is it possible to get an object to the Context of the device connected to a machine or the running emulator?
This will allow access to a system services like PowerManager or ActivityManager outside an Android device. If not via Context object, is there any other way to access the system services for a device/avd outside Android?
No way. Distributed android API classes are merely stubs good enough to compile against them.
Even most innocent stuff is stubbed out to throw RuntimeException on invocation. If you like to know status of the system, you will have to use SDK tools. Or write app exposing android objects via some remote access technology
I very much doubt that it is possible. The distributed SDK classes do not include many parts of the internal API. See, for example, this thread. Besides, what use would there be to have a system service object like PowerManager without a system (or an emulation of one) to back it up?
It sounds like what you're trying to do is not really access things on the device, as much as remotely control the device. In this case, there are some external tools that you should look into. The tools are mainly focused on testing, and are based on instrumentation for apps. You can look at robotium and monkeyrunner, to start with, as they provide a bit of functionality that might help you accomplish what you want. Other than that, you can also do what those tools do and write an app which listens for intents from adb, performs actions based on those intents, etc..., but you'll obviously be doing a lot of communication at a high level, so this might not be the most efficient (and I'm not sure how you'd transfer much data, which would be required for real RPC, which it sounds like you want to do).

controling network communication

I need to develop an Android application that sets up connection via WiFi with computer and then sends packets with data. Jowever, I need to control send packets, not only theirs data but also headers, there should be possible to modify any field in their header as well. In windows in it is possible with use of winpcap and jpcap, and I wonder if sth similar I may find on Android. Is there any ready API that will help with my problem?
There's no API available to a Java/Dalvik app on Android which would allow you to do that.
Android is a Linux system, though. So you could try to find/write one or two Linux applications to support your effort - or use JNI.
Bottomline: Native code will definitely be necessary to achieve what you want, no way to do this in Java alone.

How does android.net.sip bypass firewalls?

I'm planning to implement a simple VOIP feature, using the new android.net.sip in Android 2.3, as an extra feature of an existing Android application. Earlier, i.e. before 2.3, I tried to do a naive solution but I could not connect the other mobile phone because of the carrier network operator's firewalls!
So, I wonder, how does this new SIP package in Gingerbread bypass those firewalls, allowing mobile phones to connect directly to each other? Or will there be problems anyway? (I scanned Googles Android documentation but could not find any information on this topic.)
Thanks in advance!
/Steve
You're making an unwarranted assumption that there's a (hidden) mechanism for bypassing/traversing firewalls. Maybe there is, but quite possibly there isn't. The overall SIP documentation looks thin; this feature may well not be ready for general use, or you may well need to implement such things outside of it (STUN, TURN, UPnP, etc).

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