yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] bargie:
Quick question guys,

I thought I had this figured out but it wasnt to be..

I'm trying to give users the option of changing the background of their floating window by sliding a seekbar and I'm completely lost now as how to do it.

I'm good with making the seekbar and settings it values and so forth, I'm just stuck on what to do with the floating window..

I was able to make it so that it was working, i.e. I had an activity with a seekbar and an on and off button and if you moved the seekbar the background color would change of the window but it had somehow got 'stickied' to the seekbar activity, so whenever I would press the back button or the home button or anything else that involved getting rid of the seekbar activity, the floating window would disappear along with it.

I have used the setBackgroundColor option, I'm having trouble with how to inflate the floating window View or i mean what else to do with it so that I can let users dynamically change the background color

So i'm kinda stumped right now as to whats happening

So to summarize, I'm basically wondering how would i let a user change the background of the floating window live using, for example, a settings activity with a seekbar. So as the user slides the seekbar the background color of the window changes along with it

Any help, pointers in the right direction will be very appreciated!
[Android Apps and Games] pingpongboss:
I couldn't follow most of the question, so I'll answer the summary.

You should just change the background color of the root view that you created in createAndAttachView().

You should give that view an id:my_root_view and whenever the user touches the seekbar, you call window.findViewById(R.id.my_root_view).setBackgroundColor().
[Android Apps and Games] bargie:
Thanks for the prompt reply Mark,

I think i'm missing some basic concept here, which is not surprising since this is my first app

I have a main launcher activity (MainActivity.class and MainActivity.xml) which displays the seekbar and i'm trying to use that to change the background of the floating window (Window.class and simpleWindow.xml), i guess what I don't understand is how to connect both of them(?)

and what should the variable window equal?

I set window = getWindow(id) in Window.class but i don't understand how I can link it up with the seekbar in MainActivity.class.

Forgive me if this is something very simple and I'm just being stupid but as I said I'm very new to all this and just trying to find my way through

thanks again
[Android Apps and Games] lglossman:
Hi people, let me present you my first Android app using StandOut which btw wouldn't have been techinically possible without it:

https://play.google.com/store/apps/details?id=ar.com.zgroup.spykit

and Mark, is it possible that you add a screenshot in the first post? That would make me very happy... :victory:
[Android Apps and Games] abotrix:
Hello. First off I like to say the millionth thanks for this wonderful software to use. I have created this floating calculator and is just about finished. The background for my app uses a nine-patch on a canvas and then I used setBackground() for the BitmapDrawable that the nine-patch is attached to. As a option I have a seekbar to change the opacity of the background and it works perfectly except for one issue. If I slide the seekbar and get the alpha effect I want using setAlpha(), as soon as I move the window from the titlebar, press any button, or tap outside of window the background BitmapDrawable sets back to the value of 255 unless I tap the titlebar to bring window to front. I understand its a hack, but is it possible to automatically bring window to front without tapping the title bar? Thanx a bunch...
[Android Apps and Games] M.Kordiak:
Changing Position

Hi guys,

Great thanks for this library, very cool.

I was attempting to animate my window across the screen.

But rather than getting a scrolling effect, the position at least appears to only update at the end of my loop.

I'm probably missing something obvious, any suggestions would be appreciated.

for(int i=0;i<50;i++){

Window window = getWindow(id);

window.edit().setPosition(200, 300 + i).commit();

}

Thanks all!
[Android Apps and Games] pingpongboss:
Is there any code that changes the window alpha besides your own? Like the losing focus code for instance.

All android UI, including views, run on one main thread. So if you have code that updates the ui, that code must run to completion before any changes take effect. This is why I didn't have to write commit() for the Editor, but I wrote this before I really knew anything ^_^

This is super hacky, but you could post each position update to a Handler.
[Android Apps and Games] M.Kordiak:
Thanks ppb I'll give that a try when I get home tonight. :D

On a side note, I gave xml animations a try with this as well, I ran into a different set of issues there. But I'm pretty sure they're solvable. If you had to pick, which method would you deem better for achieving my goal?
[Android Apps and Games] pingpongboss:
It depends on what animation you are trying to do. Animating a progress bar -> use xml animations. Moving the window around -> I'd roll my own animators with ObjectAnimator or ValueAnimator.

Try setting the flag FLAG_WINDOW_FOCUS_INDICATOR_DISABLE
[Android Apps and Games] pingpongboss:
If i'm understanding correctly, you are asking how to send a signal to the floating window from your Activity.

You should use StandOutWindow.sendData() https://github.com/pingpongboss/Sta...rc/wei/mark/standout/StandOutWindow.java#L205

In the provided examples project, the WidgetsWindow sends data to the MultiWindow. You can see how it's done here https://github.com/pingpongboss/Sta...e/src/wei/mark/example/WidgetsWindow.java#L45
[Android Apps and Games] abotrix:
I don't think so. I started a new Window object to start an animation for the background but thats it. Could it be the orginal window is losing focus?

I have this in the createAndAttachView:

w = new Window(this);

w.startLayoutAnimation();

Also the calculator is an two in one combo so when I switching the calculator, a ViewFlipper starts an animation as well.
[Android Apps and Games] M.Kordiak:
I'd be crazy if I thought I might be able to use ObjectAnimator on the Window itself right?
[Android Apps and Games] pingpongboss:
Did you see my suggestion to set the focus indicator flag?

An ObjectAnimator can be set on any object (thus the name!), as long as that object offers a public setFieldName() method. So no, using an ObjectAnimator on a Window is just fine.
[Android Apps and Games] abotrix:
I not sure how to set the indicator flag. I have seen StandOutFlags.FLAG_WINDOW_FOCUS_INDICATOR_DISABLE but I don't think your talking about that. I know when the program starts I am able to actually use the buttons without a problem so I think I have focus on the window. I have a png image to show if user is using the system instead of the app (I guess to show that its out of focus). Tap out of app, png shows up, tap in, png go away as intended.

I have these flags available for the app:

StandOutFlags.FLAG_DECORATION_SYSTEM

| StandOutFlags.FLAG_BODY_MOVE_ENABLE

| StandOutFlags.FLAG_WINDOW_HIDE_ENABLE

| StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TOUCH

| StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TAP;

StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TOUCH doesn't seem to do anything but StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TAP works when I tap the titlebar.
[Android Apps and Games] pingpongboss:
Yes, I do mean FLAG_WINDOW_FOCUS_INDICATOR_DISABLE. If that flag doesn't work, you may have to restate your problem again very simply in a sentence or two.
[Android Apps and Games] abotrix:
Sorry for the confusion. My issue is when I use setAlpha() on my background, anytime I do anything else right after setting it (like moving the window around), the background image jump back to 100% opacity. I just try the FLAG_WINDOW_FOCUS_INDICATOR_DISABLE and when the app starts it show the png image I have to show the user the window is out of focus, but the issue remains. I can send you the apk if I'm not making any sense. I've been only programming for 2 years, still feel like a novice sometimes.
[Android Apps and Games] pingpongboss:
The background image jumping to 100% opacity... hm. A lot of other apps that use StandOut have the same alpha-alterating capability that you just described, but they work just fine. Maybe you are setting the alpha on the wrong View. Try to put all your views inside of a "container" view, and set the alpha on that container. You might be putting the alpha on a view that is too high up the chain, if you get what I mean.
[Android Apps and Games] abotrix:
Ok, I think I see what you mean. I give a it a try later tonight (gotta take my kid to the park). I'll get back to you. Thanks..
[Android Apps and Games] MrChops:
Activity flash

Hi Mark, I can launch a window from a click event in my main Activity, and now I've also added an empty Activity whose only function is to launch the window service and close. It has a launcher icon of it's own so users can use that to start the windowed version of my app. All works well, except that some of the time, probably when the empty Activity is not in memory, it flashes up briefly and closes. I'd done some reading and concluded I needed an Activity to Launch a service via a launcher icon.

Do you know if there's a better way to launch the service or to suppress the flash? I'd imagine some users might think my app a bit hacky or might not trust it.

Apart from that it works a treat and look forward to publishing this new version soon!

Cheers.
[Android Apps and Games] pingpongboss:
For your Activity, use Theme.NoDisplay
[Android Apps and Games] MrChops:
Perfect! Ta.
[Android Apps and Games] M.Kordiak:
So I migrated out of tooling with the example code and setup a new project with a plan to use the simplewindow.

I went to setup my classes and came up with this...

This is a bit oversimplified but:

Startupwindow.class > thewindowsproperties.class > myactivity.class

I feel like I'm doing something wrong, can someone steer me in the right direction?

Thank you for all the help!
[Android Apps and Games] pingpongboss:
What are those greater than signs supposed to mean?
[Android Apps and Games] M.Kordiak:
Refers to :(

I can give a better explanation when I get in
[Android Apps and Games] MrChops:
Orientation change

I've had fun and games tonight with my window positioning when the device is rotated. I found that with the flag FLAG_WINDOW_EDGE_LIMITS_ENABLE set and the device in Portrait orientation, if I rotated it then I could only drag my window up to the mid x point. The screen width changes but the window doesn't re-measure it, so it thinks it's still how it was before the rotation. If I turn off the flag then the screen bounds are ignored and I can drag the window anywhere...which is fine actually, except if the rotation changes again then there's a good chance the window will be off-screen, either partially or fully.

So I remembered seeing something earlier in this thread about it and I managed to find some very useful info (relating to issue 13 actually). I adapted the 'checkForEdges' code posted by dud3ski (not enough posts for the link: github.com/pingpongboss/StandOut/issues/13) so that it also persists the aspect ratio if required when resizing/positioning. I hooked it up to onConfigurationChanged (remembering to add the manifest setting for my Service).

The issue I have now with positioning is say if I put my window in the bottom half of the (portrait) screen and close it (it saves it's position in Preferences), then I open it in Landscape. The window won't be visible as I'm just setting its position from preferences without checking if these are outside of the screen bounds.

Actually I doubt my users will change orientation much but it's nice to have these bases covered :victory:
[Android Apps and Games] dud3ski:
i also have the same issue. in this case, i just added a reset button where it sets the size of my overlays to default values. one solution i can think of is to have a dedicated service that listens for a change in screen orientation, and when it does it iterates through the active overlays and updates the overlay coordinates accordingly.
[Android Apps and Games] apriest:
WebView issue

Hi Mark,

Nice framework!

I found this issue is nothing to do with Standout, sorry @@

i'm making something with StandOut, and wish you could point me out a direction of an issue described below...

i put a webview in my layout xml file and set it properly in createAndAttachView.

then call the webview.loadUrl("<google home page>"); page is loaded, everything is fine.

after that i press the login button at the top right corner of google page, typing my gmail account and password.

exception occurs when i press the submit button on the web page:

08-05 10:12:54.983: E/AndroidRuntime(3893): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.view.ViewRootImpl.setView(ViewRootImpl.java:710)

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:356)

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:234)

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:153)

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.app.Dialog.show(Dialog.java:277)

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.app.AlertDialog$Builder.show(AlertDialog.java:932)

08-05 10:12:54.983: E/AndroidRuntime(3893):	at android.webkit.WebViewClassic.onSavePassword(WebViewClassic.java:2735)

would it be better if i extend the Webview class and override those methods? e.g. onSavePassword

or there's another way to solve this issue?

thanks for your help!
[Android Apps and Games] pingpongboss:
Dialog.show() does not work from a service. I don't have any specific advice so you'll have to figure this one out :)
[Android Apps and Games] triple A:
App keeps crashing.

Hi mark, everytime i run the example projects they crash. Im not quite sure what you meant by replacing with your own custom view. Here is the logcat. pastebin .com/0uWgHnhK thanks
[Android Apps and Games] pingpongboss:
Just checking: Did you follow the instructions from the first post perfectly? You may need to restart Eclipse or Clean the projects for them to build correctly.
[Android Apps and Games] triple A:
I followed all the instructions except replacing with a custom view. Since a view was already provided
[Android Apps and Games] pingpongboss:
Should be working then. Are you installing the APK on a phone or emulator? Have you developed any other apps before?
[Android Apps and Games] triple A:
Im installing it on my nexus 4, I've haven't developed any apps before. Im actually a noob to programming at all. I want to create a simple app that can tell you the colour of the app/pixel ? Beneath it.
[Android Apps and Games] pingpongboss:
You might be hitting an issue that is not StandOut related then. I suggest you try to create an app yourself first, to make sure that your environment actually works for development.
[Android Apps and Games] triple A:
You were right, reinstalling intellij did the job, Could you help me out with something else?. Im trying to make the view circular however i get a missing classes gradient and shape error (Im only editing the xml). Searching google hasn't given me a solution. oh and this is my xml file.

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"
android:angle="270"/>
</shape>

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Simple Window Example"
android:textColor="#ffffff"
android:textStyle="bold" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Move me around. Click notification to close."
android:textColor="#ffffff" />

</merge>
[Android Apps and Games] pingpongboss:
I'm probably going to only have the time to answer StandOut related questions :) Maybe someone else can help you, or you'll have to just figure it out :good:
[Android Apps and Games] triple A:
All right thanks.
[Android Apps and Games] unit002:
how can i bring it to front!

hi

thank you for your great idea

how can i bring the floating window to front even in front of lock screen?

and how can i tell the floating window to set its width and height to xml's like wrap-content

thank you
[Android Apps and Games] pingpongboss:
Don't think you can display a window in front of the lock screen.

You have to pre-calculate the width and height. No such thing as wrap content for the floating windows I believe.
[Android Apps and Games] laleeslale123:
Need help... gr8 job BTW

Hey man, Great job!.

Theres a bug. if i am in landscape mode and set the "simpeWindow (i.e.)" in the rigth-corner when im back to portrait the windows dissapear. Or if the window is in the bottom of portrait mode and you turn to landscape it get lost too.

I wanna know if theres an code sample for apps like Esheep. i wanna put an animated srited with no background and no window frames, just like esheep. i would appreciateill it.

THANKS!.
[Android Apps and Games] MrChops:
Hi Mark,

My app has had StandOut floating windows for about 2 weeks now and it's been very well received (ok, folks love it) but I've seen a small number of StandOut related crashes reported. Not a big deal really, that's only about 8 in over 7500 installations but for me that's still 8 more than i'd like! I'm not really sure if the crashes are in the library and being bubbled up and I'm just not handling them properly. Here's an example:

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:704)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:345)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1015)
at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:924)
at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:873)
at wei.mark.standout.ui.Window$2.onClick(Window.java:391)
at android.view.View.performClick(View.java:4203)
at android.view.View$PerformClick.run(View.java:17189)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)

I can see the line where the error is happening (Window.java, 391) but I don't know how I should be handling it...if I even can. I don't know what they were doing when it happened, if they tried to open the window from the main app Activity or from the Activity attached to a separate launcher icon. Google seems to give me little usable info about crashes, or I just don't understand enough about it.

Any thoughts on what I can do? Thanks!
[Android Apps and Games] pingpongboss:
Ah, you'll want to read the recent few pages of this thread to see what workarounds people have cooked up for orientation change.

For an app like esheep, just make the background window transparent. Don't forget to disable the system decorations flag.

So the stack trace tells us that a user tried to open the drop down menu and the app crashed. BadTokenException suggests that the user might have closed the stand out window as the pop up was about to appear.
[Android Apps and Games] brandall:
Sorted!

Hi pingpongboss, scrap the above!

There must have been a gremlin in Eclipse - Cleared everything and set my environment back up again and since the recompile it's working fine.

So, I blame Eclipse...... for everything.
[Android Apps and Games] Nobray:
I create XDA account for debating here. Did anybody found a way to use StandOut while developing in Android Studio?

I downloaded the zip from the first post, imported in Eclipse (works) and when I try export it from Eclipse and import to Android Studio, it doesn't work. I know, Android Studio is still EAP, but I'm accustomed to IntelliJ environment so I don't want do develop in Eclipse.

Android Studio have problems with Gradle when importing. Can't find Gradle home etc.
[Android Apps and Games] kapam:
Is there any way to check if floating window with specified id is already showing up?
[Android Apps and Games] lotdrops:
android studio

Hi,

I exported from eclipse the examples and the floating folders, and imported to android studio successfully (I have then installed on phone from studio and they work).

I exported from eclipse with the option "generate gradle build files". And I don't remember if I had to set anything on android studio, or it just imported fine (I looked up on google how to import an eclipse project).

What I haven't been able to accomplish is using the library on my own project. I managed to import the library module and android studio showed no "red error underlining", but when compiling gradle says "package wei.mark.standout does not exist"...
[Android Apps and Games] manuja95:
Thank you for this. This is amazing! I have a question about calling a class extending Standout to create a Window. I have a class called RegularService that extends StandoutWindow. I have defined the method public void createAndAttachView(final int id, FrameLayout frame) where I create the layout and put listeners. However, I want it to be able to display the window through a BroadcastReceiver class. So my plan was to ignite the RegularService class with an Intent from the BroadcastReceiver class. How could I call the createAndAttachView method from a BroadcastReceiver? Would the intent automatically call the createAndAttahView class?

thanks for what u have done
[Android Apps and Games] pingpongboss:
All the Android Studio problems, I don't think I'll be able to help. I'm using AS exclusively at work, but I haven't tried it with StandOut. Good luck!

I blame Eclipse for everything, and 99% of the time I'm right.

You can use isExistingId(id) and getWindow(id).visibility

You can edit the StandOutExample files at first to get a feel for how the framework works. But when it comes time to use it in your own project, you will need to add the StandOut library as a library dependency for your own project, and edit your AndroidManifest file to match how the example manifest is.
[Android Apps and Games] manuja95:
Ok thank you this is great. Thank you I found my answer. I am having another problem. How can I transfer a String from one class to my class that extends StandOutWindow. For example, I want to get a String in BroadCastReceiver and set it on the StandOutWindow extending class. I tried using a set method but did not work. Any idea?