Hi,
I would like to be able to detect if my Activity has been obscured by, say, a system alert or some other overlay (for example the power menu when I long press on the power button, or the volume control Toast), or some malware that detects the launch of my Activity. I noticed that the foreground app in this case would still be my app, so I can't simply base it on what the foreground app is. I also notice that onPause() isn't called when my Activity is obscured, so I can't put any logic in onPause() either. Even if I can though, I would then have to differentiate between a system alert/overlay and the user pressing the back/home button.
Are there any other ways for me to accomplish this?
I am able to partially accomplish this by placing OnTouchListener to my UI elements as well as the root View. In this case, if the overlay relays touch events to my activity, AND the part of my Activity that was touched is obscured, then I'm able to detect that it's obscured and do something about it. However, it still doesn't guard against 2 cases:
1. If the overlay doesn't relay touch events to my Activity. In this case the OnTouchListener won't be called.
2. If the area that was touched is not obscured by the overlay, in the case of a partial overlay. In this case, the OnTouchListener won't know that the Activity is partially obscured, it only knows that it's not. This still leaves me open to a peephole attack.
I'm not convinced that there is a way. I know one can detect that the app is paused or exited, but not that it's obscured.
Related
I'm adding a GestureOverlayView and Button to the top level window
Code:
mWindowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
so both components always appear on top of every window. I'm arranging the layout programmatically then adding them (WindowManager.addView) from a Service and managing the onClickListeners from this service. The views appear as expected and the clicks are detected also.
The problem is that both the button and GestureOverlayView do not visually update correctly. The button background doesn't change (a normal button turns orange, right?) when pressed, so I ended up setting the background manually in the onTouch method with setBackgroundDrawable on both ACTION_DOWN and ACTION_UP.
The GestureOverlayView lets me draw gesture lines as usual but normally (in an Activity) when you release your finger, the yellow line is removed. For me, it isn't. What am I missing here? I kind of hacked together a fix for the button but the gesture has stumped me.
Hopefully someone can point me in the right direction as I'm not finding what I need, if it's even possible.
I need a button that is full-scrren transparent, clickable, but I want to see a ListView of items "under" the button.
I can make the full-screen button transparent and add items to the List and then just bring up the list in another Activity no problem.
But this is a client request to see the list under the button.
Anyone care to point me in the right direction...Overlays? FrameLayout? Custom Theme?
Thanks,
Roots
not really sure if I know what you mean, but you can try to make a png that is transparent and then assign it as your background image of the button in the xml file
Imagine a button that is full-screen and normal "gray" color.
Imagine a listview of some data displayed "under" that button. You make the button transparent and you can now see the list. All in the same Acitvity.
So cant stack 2 clickable items and have them both respond to clicks
Well, I tried a FrameLayout and it worked, sort of. LOL
I clicked the "invisible" button and saw my list grow in the background, but it seemed to "stop" when I hit the end of the screen.
The client is quite adamant about this requirement, but I might be able to sell them on having their data on a third screen and they can get to it on a hard or long button press. This app IS timer dependent, but the second or two it would take to bring up the data on a third screen can't be show stopper...I hope
Well, I've made some progress on the transparent button with another Activity's data showing underneath, but I still have one problem. Bear with me, this app can be confusing.
I have a screen that is a full-size transparent button. In the Manifest, it's also set to Translucent theme.
On press, it runs another Activity which has a button that adds text next to the button. Problem is, when I go back to the original activity, I can still see the button, but the setText("whatever") data is gone! If I don't make the full-screen button as "visible", the text is there.
So, I understand the concept of the setText disappearing, but why is the button still there? I need to see the text too. By the way, the button is visible when I first start the app (as it should be).
It's like I need a "setStaticText" method for TextView. I have returned the data to the calling Activity and can display it fine in a Toast. I even setText() it there, But as soon as that button goes "visible", goodbye text
Any and all ideas welcome!
On my NST Glowlight, I have a case that is beautiful but unfortunately covers the back power button (Verso Prologue Antique Tan, currently a steal on Amazon at $10). When I close the cover, it bumps things on the screen and either opens random books (in ReLaunch) or loses my place (in Coolreader). Does anyone know of a simple app that triggers the screen lock so I can map it to a hardware button? I set a "Lock Screen" shortcut in ReLaunch but at least half the time it doesn't work (instead, it asks if I want to power off). Thoughts?
Install Button Savior and tap its on-screen power button.
cowbutt said:
Install Button Savior and tap its on-screen power button.
Click to expand...
Click to collapse
IMO Button Savior is an eyesore and I can already duplicate all of its functions with hardware button mappings. I want to be able to map power to a hardware button, which I know I can do if I have an app shortcut of some sort.
OK, I found my own solution and it works well enough that I thought I'd share.
I found a whole bunch of screen lock apps but they all require Android 2.2 or later.
Thinking outside the box, I instead downloaded a simple app called "White Screen Flashlight" and mapped it to my n button. Now if I push n the screen goes completely blank and doesn't register touch input, so it's safe. I have the added benefit that if anyone swipes my Nook and wants to see what I am reading, they get a boring empty screen when they turn it on. Sleep mode kicks in as normal.
Alternatively, use http://forum.xda-developers.com/showthread.php?t=1848962 to set a Lock PIN. I combine this with a Tasker rule that disables the PIN if I'm connected to a 'friendly' WiFi network (i.e. my home WLAN) and re-enables it when I disconnect.
cowbutt said:
Alternatively, use http://forum.xda-developers.com/showthread.php?t=1848962 to set a Lock PIN. I combine this with a Tasker rule that disables the PIN if I'm connected to a 'friendly' WiFi network (i.e. my home WLAN) and re-enables it when I disconnect.
Click to expand...
Click to collapse
That is a great idea! I previously set a lock on my Nook ST (pre-Glowlight), but this time I'm simply keeping it disconnected from Google and any sensitive information. There's a bar on the screensaver that gives "please return to..." information. I figure if someone steals it, they won't get access to anything but some books, and if it's lost, a kindly soul may return it.
Hi,
I am developing an application for a specific tablet which have two physical buttons, the home button and the back button and have a simple launcher which launch a web browser. My launcher has system permissions, but I couldn't change or modify the android Rom , I am not root, and I can't be. Do you know if there is a way to prevent the home button to be pressed or to catch the event. I tried to overdrive onKeyPressed, it worked for the back button, but not for the home button.
If you have any idea, I am listening.
Thanks for your help.
How are you going to change system app without root?
Anyways, there is no documented method for it. There was a hack during GB times but it was fixed in higher versions so its useless now.
What you can do is make your own instamce of a launcher and catch the home button action to do whatever you want after that. You won't be able to do it without setting up your own launcher.
This is not a phone or a usual tablet, the tablet is created just for our usage, but the manufacturer don't want to produce tablet with root because we will sell those tablet for the public. I created my own launcher, this launch install my main application if it's not installed or launched it if it's present on the device. When I am in my main application for example browsing the web or playing a video, we don't want customers to be able to quit it or finishing it by clicking on the home button
ghostwan said:
This is not a phone or a usual tablet, the tablet is created just for our usage, but the manufacturer don't want to produce tablet with root because we will sell those tablet for the public. I created my own launcher, this launch install my main application if it's not installed or launched it if it's present on the device. When I am in my main application for example browsing the web or playing a video, we don't want customers to be able to quit it or finishing it by clicking on the home button
Click to expand...
Click to collapse
If you want the customers to be able to access only a single app, you can do something as simple as just setting it up as the home screen. Put this in your intent filter in your manifest.
Code:
<category android:name="android.intent.category.HOME"/>
This will always bring up the main activity of your app whenever the home button is pressed.
Hi
I have two activitys and have following use case:
If user presses in the first activityOne the home button, onPause() is called. In onPause() I'd like to send an intent to the second activity to launch it.
Technically it works, but there is a huge delay betwend pressing the home button and launching the activity, about 4-6 seconds. If I send the intent by any other button pressed, it switches immediately.
Is it possible to speed up the switching or is this a given android behavior?
Regards,
cloooned
its a pretty bad level of coding to start an intent when onpause is called. consider just pressing the home button of your phone to exit the app leads you to some other activity instead.
also onpause will only be called when the activity goes to background. it will take a bit of time to reach that point.
Since the key event has been removed from the home button in Android 4.x, it seems to be one of the few chances to catch the home button pressed event. One other possibility is to overwrite the launcher with the activity and change the launcher default settings, but this would go to far.
Android prohibits you from starting an activity (from an intent) within 5 seconds after the user presses the home button. All startActivity intents will be delayed and executed after this 5 second interval. It is bad practice to start a new activity when the home button is pressed since the home button is the users last resort to escape an application.