Silent push notifications only delivered if device is charging and/or app is foreground

We have experienced the same behavior and have been trying to understand why iOS decides to deliver some notifications and not others. What we have worked out so far is: Messages will get received more reliably in background when on wifi than on cellular data. In fact, when on a cellular network (3g/4g), if your … Read more

How to programmatically round corners and set random background colors

Instead of setBackgroundColor, retrieve the background drawable and set its color: v.setBackgroundResource(R.drawable.tags_rounded_corners); GradientDrawable drawable = (GradientDrawable) v.getBackground(); if (i % 2 == 0) { drawable.setColor(Color.RED); } else { drawable.setColor(Color.BLUE); } Also, you can define the padding within your tags_rounded_corners.xml: <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <corners android:radius=”4dp” /> <padding android:top=”2dp” android:left=”2dp” android:bottom=”2dp” android:right=”2dp” /> </shape>

Listen to key press when the program is in the background

You can use P/Invocation to be able to use WinAPI’s GetAsyncKeyState() function, then check that in a timer. <DllImport(“user32.dll”)> _ Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short End Function Const KeyDownBit As Integer = &H8000 Private Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick If (GetAsyncKeyState(Keys.LWin) And KeyDownBit) = KeyDownBit AndAlso (GetAsyncKeyState(Keys.O) … Read more

swift NSTimer in Background

You shouldn’t be messing with any adjustments based upon when it enters background or resumes, but rather just save the time that you are counting from or to (depending upon whether you are counting up or down). Then when the app starts up again, you just use that from/to time when reconstructing the timer. Likewise, … Read more