How to keep counter adding while holding a button - app-inventor

I am trying to make a counter that will add +1 while holding down a button in MIT App Inventor.
I have tried recursion and the while loop.
The app crashes.

There is only one thread for App Inventor apps, so the while loop will crash your app after a while... Use the clock component instead...
Some helpful links
The model of event processing in App Inventor by Lyn
The 'Do something' example

Related

App Minimized Function? Xcode - Swift

Just a quick question to ask how I can check if my app has been minimised? IE Home button been pressed?
Having a problem in my game where it's constantly building up more and more nodes at the top of the screen and I need to call the pause game function when the home button is pressed.
Thanks in advance
PS Xcode 6.4 -Swift
When the app goes to background, the function applicationDidEnterBackground in the appDelegate gets called (and then you have something like 5 seconds to clean stuff)
in addition, The system sends the UIApplicationDidEnterBackgroundNotification notification in addition to calling the applicationDidEnterBackground: method
so you can listen to this notification

Windows Phone : Event when you close app in the active app list

If I close my app with the back-button, the event Application_Closing is raised and the code is executing.
When I close my app in the list with active apps, no event is raised...
I really need an event for this.
Does anyone know a solution?
There is no event to detect when your app is terminating from the app list. When your app goes to background it will be tombstoned.
You can react on this with the Application_Deactivated event. So you should handle both events Application_Deactivated and Application_Closing.
Learn more about the app's lifecycle here.

Watch face and user action

Is it possible to add any user action to a watch face application?
I'd like to add a button on a watch face that triggers some logic.
When I deploy the watch face application for the first time, the touch events are routed to the button and I can do fun stuff.
Once the clock goes to sleep, then Google takes over, and all my touches trigger the default google voice search.
I assume that the google voice takes over the whole surface, as a layer, and my button never receives the button pressed events.
Is there a work around like, I can swipe from right-to-left to get an action button?
Is there a way to disable the google voice search from a watch face?
Thanks in advance,
-Jukka

Detecting when the "Thank you" message has been dismissed after IAP OSX

I am working on a game on OSX with In App Purchases.
I am trying to detect when the Popup that says "Thank You, Your purchase was Successful." At the end of a successful Purchase by the user.
The Problem that I am having is I need to hide the mouse and resume input on the game after this message has been dismissed, but I can't find a suitable place to do this.
How can I find out if the OK button has been pressed on this message box?
Okay, so I found a fix to my problem.
I couldn't find a way to detect when an alert is shown from another Application, as all the the In App Purchase popups come from the App Store.
The fix I used was to make sure that the App Store was open before starting the transaction. This means that OS, whether or not you are in full screen, will automatically take you to the App Store. This causes the Alerts to be shown as sheets inside the App Store rather than in front of your application. Problem solved.
I open the App Store immediately before instigating the transaction by calling this line of code:
[[NSApp mainWindow] makeKeyAndOrderFront:[NSApp mainWindow]];
Then once the transaction finishes I grab focus on my App again.

EmailComposeTask / SmsComposeTask loses my app state

I'm developing my first Windows Phone 7 app. I don't yet have access to an actual device, so I am relying on the emulator that ships with the SDK.
In my app, I use the EmailComposeTask and SmsComposeTask where required. When debugging my app in the emulator, I click a button which runs one of these tasks, and it works. But when I then push the back button to get out of the task and back to my app, the app state is lost - it's as if I am launching it fresh all over again.
But, where it gets weird, is that on occasion this doesn't happen. I have gone back from one of the Tasks more than once to find my app state exactly how I left it.
And so, my questions:
Is this just a bug with the emulator?
If not, why is not consistent, and how should I be "saving" my app state prior to call the Email or SMS task?
Thanks.
Your page is being tombstoned which is why it seems like your application has restarted. This basically means that your app is still stored on the stack, ready to be called, but pages state and other data information is lost. To fix this, you need to handle the serialization of any data you want to keep.
For transient data, like page state things (e.g. textboxes, checkbox etc..), you can use PhoneApplicationPage.State. I believe the limit is 2mb. If you need to store more, you should store it in Isolated Storage (unlikely, unless you need to save an image). You can read about the process here. To understand the process of Tombstoning, you should read this MSDN page. To save time, you can use Tombstone Helper which handles all the lower level storage details for you, but it's a good idea to understand the process of Tombstoning anyway so you know what's going on.
The reason your app doesn't always get tombstoned is because EmailComposeTask doesn't cause a tombstone straight away. From this MSDN blog post:
Below is the list of native
experiences that, when invoked, do not
trigger an automatic tombstone in the
calling application:
PhotoChooserTask
CameraCaptureTask
MediaPlayerLauncher
EmailAddressChooserTask
PhoneNumberChooserTask
There are three scenarios in which an
application in the background will
immediately be tombstoned:
User forward navigates away from an application [for example, user
presses the Start key]
Application invokes launchers or choosers not listed above
System requires more resources to carry out a foreground activity
As you can see, that's not to say EmailComposeTask will never cause a tombstone, so you should still handle it, but it explains why your page state is sometimes kept automatically.

Resources