I am looking for some help, not being spoon feed source code (which from some of the threads I have read on this forum wouldn't happen anyway). I am really just wanting to know if what I have conjured up in my head is even possible or not, and if it is if I could get pointed in the right direction. So, I am looking to add a "view", doesn't really matter what type the concept would be the same for all of them, to appear when receiving or placing a phone call. You know the one that has the little droid waving at you or a photo, etc. The only thing is that I would only want like the top 30px to be this "view".
For instance, you receive a phone call and at the top of your screen on top of the receiving call window is a TextView with a note about this person (i.e. - he stinks).
The only thing I have been able to come up with so far is that I would have to bring up a layout that was either invisible or gone, but have yet to figure it out as of yet.
Am I barking up the right tree or do I need to find a different tree to sniff. Any and all help would be appreciated.
I honestly don't know the answer to this, but if it were possible then presumably you would have to have your own custom Activity launch in response to an incoming phone call event. This Activity of your own would replace the standard system phone application. So I did a search on here and the most vaguely related previous questions I could find within a short time are these:
Is it possible to write a new "phone" activity, and if yes then how?
Launch an activity at end of a phone call on Android
Answers on those seem to suggest the phone would need to be rooted before you could replace the standard phone app for receiving calls.
Related
I would like to display a message to the user for some asynchronous event. For example for an alarm expiration. I would like to display a popup or dialog that is displayed over any activity is the foreground at the moment (and this can be some other application activity) leaving the current activity in the backgound.
Is there a way to do so in Android?
First off, you will be told that this is a bad thing to do, that it is against the Android way of doing things. Users do not like this. And that the Notification area is much better way to do this.
That said... there are ways to accomplish this...
A Toast will display no matter which activity is on the screen. So you could set up a background thread (or better a Service) that will display your information in a Toast. This might be good enough for you.
You may find it useful looking at some Toast source code here.
Also here is a nice page on how to create a custom Toast layout by replacing the default View with one of your own. (I have not done this, but it looks quite interesting):
Custom Toast Alert on androidexample.com
The alternative is much more difficult, and is to display a System Overlay window. Unfortunately you have to do quite a lot of work to get these set up properly.
Here are a few related questions that I used to get it working:
Creating a system overlay window (always on top)
System overlay android 4.0
How to create a system overlay in Android which allows interaction with the windows below it?
Each of these has links to many others - there are loads of System Overlay questions on here.
But things to remember:
In the old days, you could put a system overlay on top, and send
touches through to the activity below. This is no longer possible,
and so a lot of the answers are now out of date.
You may need to
play around with the flags in the provided examples to get exactly
the effect you are aiming for. Not all the examples use the same
flags, so there are some subtle differences in how each solution
works.
Then again, I also believe that the Notification area is a much better UI pattern to use, so I do recommend you try that first. It is easier to do, and most of us expect that type of behaviour rather than a pop-up.
The problem with a pop-up, is that it might interrupt a movie I'm watching. Or a game I'm playing.
Yes, i had created two dialog for income event for background and foreground
I want to be able to tap the statusbar and the contents in the displayed app to be scrolled up to the top.
Is it technically possible that an app intercept my tap and send the appropriate command to the active app? I have noticed for example that AntTek quick settings shows a drop-down window when swiping down from statusbar. While using the app I did also notice that even by just tapping the statusbar (before beginning to move the finger down), the app seems to already interact with the touch as it dims the screen brightness in preparation to display it's "window" (sorry I use the MS Windows term), so clearly a statusbar tap CAN be sensed by an app.
Starting from this, I wonder if such an app could then send a message to the active program telling it to scroll up.
Is that possible? And if yes, the message must be customized to a particular app (let's say the browser as the most important) or is it standardized so the apps speak the same language between themselves?
I am not a programmer so answers with codesamples might be less helpful than a plain english explanation. Finding out that is possible would lead rather to pursuing a programmer to implement the idea rather than starting to develop it myself.
Thanks :-)
There is an XPosed-module which seems to do exactly what you want.
To use XPosed-modules, you'll need to root your phone and install the XPosed-framework.
The XPosed-module is called "Statusbar Scroll to Top" and its repository can be found here:
http://repo.xposed.info/module/com.mohammadag.statusbarscrolltotop
This will work for almost all app-lists, but for example won't work for browser-content.
If you want to scroll to the top of the page in a browser, then you'll probably do best to get a browser which can do that on its own. (For example Habit Browser has it built-in and respective plugins are available for Firefox.)
Yes it is possible. HiroMacro and Frep can do this, but it requires root. https://play.google.com/store/apps/details?id=com.prohiro.macro&hl=en
(how do they simulate mouse and keyboard interactions on other applications? i have no clue :/ anyone?)
Is it technically possible that an app intercept my tap and send the appropriate command to the active app?
No. One app cannot send fake input to another app, for security reasons.
An android app comprises of several activities. Each activity display a GUI that allows the user to perform a specific task. To take the user from one activity to another, app must use an Intent to define our app’s intent to do something.
An intent can be explicit in order to start a specific component (a specific Activity instance) or implicit in order to start any component that can handle the intended action.
Interacting one app to other app in android
google docs link
I'm developing an app that intercepts toast messages and displays them in a custom view.
The interception part is easily implemented using the AccessibilityService.
The tricky part is how to suppress the toast messages from appearing (or at least make them invisible). I know (to the best of my understanding) that this is not possible in normal circumstances.
But does anyone know any hacks that would allow me to suppress the toasts from appearing or make them invisible?
Would it be possible with root permission?
Note: I'm relatively new to programming. Nonetheless, I had a look at the android source code for Toast.java (link). Would it be possible to intercept the show() method or any other relevant method to stop them from appearing (maybe with root permission)?
According to Dianne Hackborn here, you can't. Yes, I realize that post is over four years old, but I haven't seen anything in the SDK since to overcome that.
Yes, you can use an accessibility service to detect toasts, but that's only so you can do something in addition, like TTS, not to stop them.
It would be a bad day if you could. For example, junk apps that pastes shortcuts on your desktop. Root apps that require SuperUser. In both cases, a toast pops up to let you know that something out of the ordinary is happening. That's a good thing, and if I ever found an app that was suppressing toasts, it would be gone instantly.
Moral issues aside, you could do this if you changed the OS source and compiled it on your own, but it would still only work for users that had that particular ROM installed.
As another option, have you tried creating your own Toast instead? You can give it a custom View, and if it's timed right, it will show up just after the normal one. Then it would overlap and you won't see the first. I'm not sure how feasible it is, but it's a thought.
Im currently trying to get my diploma in psychology and i want to write about different types of keyboards for smartphones. To research this area i need a tool that measures times. As Im new to Android programming, my friend is helping me, but we got stuck.
Here is what we need, and what we tried. Id really appreciate any help =)
We need a way to call a function before user input in IME begins and after user input in IME ends. (We need this only for timelogging, we dont need the actual input.)
We also need to call a function before user input for chosing autocorrection starts/ends.
We need to do this for all kinds of IMEs especially keyboards
like Swype, Swiftkey etc (though one of them working is enough)
We tried:
TextWatcher via addTextChangedListener
- seems to be unreliable to get the times beforeTextChanged/afterTextChanged is randomly called, even within a gesture
or multiple times within a gesture
subclassing EditText implementing OnTouchListener,
using onTouch()
- didnt seem to get called at all when using swype, so either we did it wrong or ime/swpye consumes those events,
also tried it with onKeyPreIme, wasnt called either
Ideal would be:
a way of catching the "touch" events before they are passed to the IME to log the current time via System.currentTimeMillis()
the same "after" the gesture ends i.e. when the finger is released from display
we dont need actual code, a link to the right command/documentation/widget would be sweet.
You get bonus cookies if you are ever in berlin and need a place to ... get cookies :)
Not sure if this is much of an answer, but...
Is your plan to write this in an Android application that you can distribute and run on anybody's device?
Sounds like whatever you do on the EditText or your application may not be enough because the IME is a separate module in Android, so you would not be able to get any information about auto correct or prediction or things like that (different IME have different of such features). You would only be able to get the text entered (or removed) from the text entry.
The best I can think of is for you to develop your own IME, then you can log anything you like in there.
To go about that, I would suggest, you first checkout this article from Android Developer:
http://developer.android.com/guide/topics/text/creating-input-method.html
And then you can check out the source code for the default Latin IME there:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/inputmethod/latin/LatinIME.java
Although this one has probably much more than you need and has (I think) some links into the Android framework itself, so you cannot really build it as a separate module the way it is now.
Hope that helps
I went through some posts, but most of them discuss placing a image or a string with information on it.
I however need to place button that manipulates some call features.
Is there a method to do that universally works throughout all android distributions?
(I thought to pop up custom screen with my button above usual screen. Is that good idea, or is there more straightforward way to achieve this?)
Thanks a lot
On stock devices there isn't going to be a legit way to put your own button "on" any portion of the Dialer application Activities (including incoming call screen). This kind of functionality would require the Dialer to explicitly provide an API for it. The stock system prevents applications in the background from placing their own clickable regions "on top of" whatever is currently in the foreground . (It's a good thing too, the bad reasons to do this far outweigh the legit ones.)
If you are wanting to do this you're going to have to look into building your own version of the OS that allows for it. OR potentially if you unlock your device enough to be able to install your own application that handles all of the functionality of the Dialer. Then you could provide an API for a third party application to do it(or just "bake in" your button to the Dialer) But I imagine that being able to get it all hooked up correctly to actually make your calls would be mighty difficult.