Pop up activity closes on touch event in some phones - android

I have a strange problem. im developing an app which overlays the incoming call screen. I have achieved displaying the popup window and everything works fine also i can access the receive and disconnect call controls below the pop up window on my galaxy s2.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
i've set the flags on my window to achieve the desired effect. But the while running the same code on galaxy s3/note 2. whenever i touch the screen anywhere my activity disappears! i have written methods to perform different actions on if the call is picked up or dropped. But i can never call those methods as the activity destroys itself just upon touch at any point of the screen.

Related

Bringing activity infront of the callscreen

I've created an application which shows a dialog when phone receives a call from a number starts with particular string. To achieve that I created a transparent activity and created a dialog like UI. It works fine on the emulator because emulator shows stock caller UI. But for the real devices it has a full screen UI for the caller screen which hides my transparent activity. Is it possible to bring that activity in front of the caller screen.
I solved this issue by getting request from user to overlay on system UI and my transparent activity is overlaying on it

Delegate event from my activity to screen

I have a activity themed like a dialog and I have it setup so that it finishes when the user click outside.
this.setFinishOnTouchOutside(true);
As expected when the user clicks outside, it finishes. The activity is marked as floating activity and is only shown on top of the phone.
Now, if the user click on any other part of screen like the phone button/contact button on home screen, then the activity gets finished, but the user has to click on phone/contact app icon again to open phone/conatct app.
What I want is that if user click outside my activity, then the action must be performed as if the activity is not at all present on screen. Something like notification, which does not prevent user from doing other other tasks.
The only way you might be able to do this is by using a hidden WindowManager.LayoutParams flag, FLAG_SLIPPERY.
This allows touches starting on your View to continue to whatever View is below when the touch leaves your View but remains on the screen. However, I don't think this will work.
Android prevents you from touching "through" a touchable Window because it assumes that Window should be receiving the TouchEvent. Android also prevents you from programmatically "touching" the screen (without root or system access), most likely for security reasons.
I dug through AOSP for a while and found this.
Reading the comments, it's possible to infer that, while what you see doesn't take up the whole screen, the Activity's Window does. So, while nothing in your Activity is clicked, the Window is still overlaying everything, just with a transparent background, and is dealing with the touches that aren't passed to your Activity's UI. This brings us back to the "touching through" issue.

How to disable Android touch

There are some application that disables all the touch inputs, including the touch events that occur on the navigation bar.
Examples are Touch Lock or UnTouch. How one can do that?
By analyzing the second linked app seems that there is a hidden layout that capture the touch events (like an empty onClickListener).
Initially I tried to draw a transparent foreground using the SYSTEM_ALERT_WINDOW permission and by assigning an empty touch listener. However in this way I cannot draw on the navigation bar, so the user can touch the home button and the back button.
Another way that I tried is to launch an Activity with transparent background and in fullscreen mode. In this way I can capture all the events. This works, but obviously this causes other activities to go in pause state.
So my question is, how can one reach the goal? Alternatively is possible to use some root/system commands?
Thanks!
Try this link. If you want to do it on just 1 view then edit out the iteration in the methods given.

Dialog rendered behind Home Activity

I am working on a complex Android app and found a strange problem.
The problem occurs when I start an activity to show a dialog.
What have I tried
I tried to search for similar problems ("Android activity blocked by home activity" etc) but could not find any.
Due to the complex nature of my app, I still cannot find the minimum representation of the cause -- The Description section below cannot be used to reproduce the problem. It is just something that I think is closely related to the problem. The real cause could be interactions between different subsystems.
Description
The activity is launched by a service with intent flags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP, which ensures that it will be the topmost activity at the point when it's launched. In its onCreate method, the activity set its window flags to be FLAG_SHOW_WHEN_LOCKED | FLAG_FULLSCREEN | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD, which ensures that even if the screen is locked, the activity will still be displayed. The dialog is also built and shown in the activity's onCreate method.
The app is tested on Android phones with screen pattern locks using the following steps:
Start the app. Press home button to return to the home activity. Remove the app from the recent app list.
Turn off and lock the screen by pressing the power button.
Ask (through GCM, to be specific) the service to launch the activity once. Dialog is then successfully shown.
Don't click any button on the dialog. Lock the screen again.
Ask the service to launch the activity once more. This time the dialog is also shown but instantly disappears, leaving the screen pattern lock shown.
Unlock the pattern lock and something strange appears: The dialog is now shown behind the home activity. The dialog doesn't respond to touch event. It's just like a wallpaper.
Android Version seems to matter
The problem seems to be only affecting some of the versions. It occurred on a Galaxy Nexus (Android 4.4.2) but didn't occur on a Galaxy Tab 3 (Android 4.1).
Accidentally the problem was solved by removing the line
android:theme="#android:style/Theme.Dialog"
for the activity containing the dialog from AndroidManifest.xml.
I am not sure why it could be solved in this way though.

Get access of launcher screen while showing activity content?

is it possible to get touch access of launcher while showing activity?
while activity covering only quarter of screen area only.
as i said make an activity layout which cover quarter area of screen, I added flag for activity getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);
it works :) to get access of launcher screen, even my activity is open. I notice another one thing i m not able to get click event on launcher, nor getting focus from my activity to launcher, it's just giving me touch event on launcher.
any one have idea over this, how can i get focus from my activity to launcher or any open application.

Categories

Resources