Monitor All Android Devices events remotely - java

In Android, I can monitor if certain events are triggered through the use of Broadcast Receivers. Are there any tools which let me view ALL events on an android device I am debugging instead of having to add a broadcast receiver to listen to them?
For example, in a Broadcast receiver, I can monitor for a call forwarding event. Is there a way to debug such events outside of having to write additional Android code? My goal is to test that certain events are triggered after UI state changes, and I am not seeing anything obvious in Logcat that communicates which events are being fired.
For example,
with call forwarding I only see cases like below in Logcat.
START u0 {act=android.intent.action.MAIN cmp=com.android.phone/.GsmUmtsCallForwardOptions}

The machine where you run an Android remotely can be any system supported by the Android SDK: Windows, Mac OS X, or Linux. The socket connections is forward from a specified local port to a specified remote port on the device instance.
It is recommended that this machine is on the same network as your development PC, for performance and configuration reasons, but it is also possible to use any remotely located machine if firewalls and routing are configured correctly. You have to follow specified steps that provide you with the necessary settings in your environment configuration that will allow you to have remote debugging.
Alternatively you can also consider using Google chrome remote debugging for Android. The jsHybugger can also offers you a similar tool that will equally allow Android remote debugging.
Indeed you can choose the approach that suits you better.
Otherwise, if what you meant is to listen to event in some application, then this has to be done by yourself by hand, including it to the respective app you want to listen for every single event. Further details on this direction you find here:
Android listen for all events in application
As you can see, Android has a lot of capabilities, but everything come at some cost - i.e. you have to code it. Otherwise, something that could be done according to your suggestion would be kind of an App or an API that would monitor every single event from all Apps currently in your mobile. But if this is what you really want, then in my view such approach would be cumbersome and overload your mobile.

Related

Controlling a device hardware via device admin or root

I need to have control over some admin features of android device.
Is it possible to acquire control over hardware not specified in android.app.admin.DevicePolicyManager like disabling access to microphone?
Also it will be good to find ability to track network connections or attempts to use network adapters by apps.
Maybe some command for root console or other way exist - how I can search for?
As far as i know there is no way to block any other hardware except camera with device manager. I believe that if your app takes control of microphone it will be unavailable to other apps, but i am not sure. Note that from android 8.0 no app is allowed to take control of microphone while in background.
About tracking network activity you could open vpn to monitor all packets that are sent and received.
Please keep in mind that i am not familiar with root methods so you should do some more research on this.

Android - Disable text message notifications programmatically

I'm working on an application that handles text messages. This is a personal application and I do not plan to release it, however it's basically going to allow me to share my text messages (and phone number) between numerous devices through the internet. It's a fun learning project too as a first application, and I've done quite a lot.
However the annoying part is the text-message popup that my device gets when receiving a message. I love it when I'm using the device, and I could always just go into the options and disable the popup when I'm not planning on using the device, but I'm a very, very forgetful person and turning it back on wont always happen. Then I'll never reply to messages.
Basically I want to programmatically interrupt (or not even notify) my default messaging application of the text message, however I still want it to be logged in my messaging history. So the message can't just be "discarded". This should only happen of-course while my applications service is running.
I've been searching through the android API for quite some time and I just can't seem to figure this out, is it possible and if so can you link me to the proper place in the API to begin?
Basically I want to programmatically interrupt (or not even notify) my default messaging application of the text message...
This isn't possible.
Assuming by "interrupt" you mean to prevent the default SMS app from issuing its Notification, you can no more do this with the default app than you could with any other app that you don't control.
Additionally, as the default SMS app responds to the SMS_DELIVER_ACTION broadcast, and it is the only app to receive this broadcast, it wouldn't be possible to "not...notify" the default app of an incoming message. Your app wouldn't even have a chance to abort the broadcast, even if it were possible to do so.
(In versions prior to KitKat, it was oftentimes possible to register a Receiver with a high priority for the SMS_RECEIVED_ACTION broadcast, and then abort the broadcast before the native SMS app received it. This is what rajan ks's answer refers to.)
...however I still want it to be logged in my messaging history.
The default SMS app is responsible for writing all incoming messages to the Provider. Even if you were able to prevent the default app from receiving the incoming message, your app would then have to write the message itself. This isn't really possible, either, as the default app is the only one with standard write access to the Provider.

How to share database between same application in multiple devices without server

I have created database in one application and that application is installed in multiple devices.My requirement is that if i change the value in database of one device then,that changes in database should reflect in another device of same application.I need it without server/third api.
Thanks in advance...
This is precisely when one does need a sever.
Stop and consider what it is that you are asking for. You need a way for a phone to notify all other phones that hold the same application about a change. Phones are not directly addressable to each other via the web, which makes any kind of peer to peer algorithm tricky. SMS texts is the closest form of direct addressing that phones do support, thus it could be used to build a peer to peer protocol, but that would be tricky, unreliable and is unlikely to be beneficial.
A server on the other hand is the standard approach to solving this problem, the server acts as a shared agent that all phones that connect to the web can address easily. Even if the server is just an FTP server on a freebie hosting site.
You need to implement a server functionality in your android application.
What is a server : A server is a running instance of an application (software) capable of accepting requests from the client and giving responses accordingly. Servers can run on any computer including dedicated computers, which individually are also often referred to as "the server".
For further information,I would like to provide this link which will clarify you about communication between two devices Android - communicating between two devices (Use of bluetooth etc.)

How to be made aware of incoming emails on GMail without frequent polling?

If I am developing an Android application, what is the most feasible way to get near real-time notifications about an incoming email? Is there a push-like mechanism, or can I hold my IMAP connection for a long time, or do I use IDLE command?
Consider that user is authorized to use GMail services via OAuth and I don't want to poll IMAP server madly.
Update:
I'm not using the phone's configured-in Google account. There is another account set up using OAuth.
I'm using Apache Commons Net to connect to IMAP/SMTP in my app. It's a bare-bone library for IMAP, but I can perhaps modify it to add IMAP commands/extensions.
You can register a ContentObserver with GMail, anytime something changes in GMail, the observer will be called.
contentResolver.registerContentObserver(Uri.parse("content://gmail-ls"), true, myContentObserver );
Override onChange in your ContentObserver to do stuff when something in GMail changes.
Since IMAP does natively provide any sort of push notifications and the Google extensions don't either, you have to implement it yourself.
One way is to use IDLE requests, which is still a cheap way to do polling. Of course, you can't expect your app to be running all the time, so you need to use a background service. An 'always-on' service is however an anti-pattern on Android and will drain the battery quickly and likely get you many 1-stars. Additionally the system may decide to kill it at any time. The other alternative is to use AlarmManager to start the service periodically, but starting it every couple of seconds or so is just as bad. So you are basically back to square one: polling.
The other way is to get push notifications using GCM or a similar service. This does require you to have a server, and the server needs to have the authentication info for the user (which might be a problem), but there are no real constraints concerning keeping open connections and sending IDLEs each second, etc. On the Android side, if you want to implement push yourself, you need to keep an open socket to get notifications. This is not very easy to do if you are not a system app (see above), so that leaves GCM. The connection it uses is manged by the system (Google Services framework), it can do things a regular app cannot, and you basically get it for free, since it's already there. It receives small pieces of data when there is something to do, called 'tickles'. Those in turn trigger broadcasts, Google Play updates, etc.
So, take your pick. Or just give up, register the account and use GMail and its labels Android API.
I'd check out Google Cloud Messaging (GCM):
http://developer.android.com/training/cloudsync/gcm.html
My understanding is that this works without requiring the user's Google account, and lets you handle authentication.
See a tutorial here:
http://www.techrepublic.com/blog/app-builder/implementing-googles-cloud-to-device-messaging/428
You would need additional server-side code running to do this though.

Java App on Mac asking for allow network connections everytime

My Java.app broadcasts a packet on the network as soon as it starts up. Everytime I start this app, the Mac asks me do I want to allow network connections blah..blah.. Can I use info.plist or something to allow network access to this app and not bother the user who has trustingly downloaded and installed my app.
Thanks
You can choose to allow incoming connections for specific services in System Preferences > Security > Firewall.
Addendum: You application will appear only if the user has chosen to "Set access for specific services and applications." It will be added the first time the application attempts to open the port.
Addendum: The application appears with the name java in the Firewall pane. Once the user chooses to accept or deny, the dialog ceases to appear. This simple example is convenient for testing.
If you codesign your app (using the same key across updates) it should work properly with the app-specific firewall on. It seems to be a bug on Apple's side that unsigned java apps are prompted for allowing network connections (even if they don't try to listen to the network) every time they are run.

Categories