02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School

Wake up ! It's not time to sleep

Our application is in test mode and it falls asleep on us what a horrific ordeal. Well not really, it's not so bad we will add a small patch to our application and get it ready to become the Flashlight it always wanted to be at night ;) and with that we completed building our first complete android application. Congrats!

Video Transcript

00:00So as really, as we said, we took the application for a ride,
00:05been using it for the last 30 minutes,
00:06and noticed that there's an issue.
00:08One is that the screen turns off,
00:10it gets locked the screen after a certain amount of time,
00:12and that is because we didn't actually tell the device,
00:15don't turn off anymore while the application is running.
00:17And that's exactly what we're gonna do in this video.
00:19So let's jump right in.
00:21Go into your Android settings for Air 3.6
00:24or whatever version you're in,
00:26and go to the permissions directory.
00:28Scroll down and find that disable key guard
00:31to make sure that a password doesn't,
00:33the keyboard doesn't get locked,
00:36so making sure that our application remains open.
00:39And make sure that also we get permission to wake lock.
00:41So we wanna make sure that disable key guard
00:43and wake lock are both configured.
00:45We're gonna click okay and save that.
00:47Now by the way, once you do that,
00:49if you go into your XML file of our ruler app,
00:53and if I just open that up really quickly,
00:55you'll notice that it will be added in
00:57into our permissions area,
00:58the actual permissions that enable it.
01:00Let me just open that up a bit so it's easier to see.
01:03We'll see that in our permissions themselves,
01:05you'll see that when we have our internet permission
01:07added in, we have our disable guard added in,
01:09and we have our wake lock added in.
01:11If you're not working with the API,
01:13if you're not working with Flash CC,
01:16the latest version where it automatically adds
01:18all this information for you without needing
01:20to actually literally go inside
01:22and make all these changes,
01:23just make sure that you download our latest manifest
01:26and make sure that you copy and paste
01:27the areas of the manifest editions for Android
01:31if you're building for Android.
01:33All right, so let's go back right into the application
01:35once that was created.
01:36And literally what I wanna do next
01:38is I'm gonna go into my action script panel,
01:40and somewhere along the beginning of our application,
01:42we wanna add that actual rules
01:44that basically tell the application
01:46that it's not going to be, oops,
01:48that it's not going to go to sleep anymore.
01:51To do that, we're gonna revisit the native application
01:53which we've seen earlier
01:54when we wanted to see what version of air we're running.
01:57To do that, I'm gonna basically load that in,
02:00and so instead of importing it,
02:01I'm gonna do that trick that we talked about,
02:03which is typing the new native,
02:07native application we're really looking for.
02:10And once we get that in, I could delete that new
02:12because we never really create a new native application,
02:15and I could approach the native application again,
02:17only this time I wanna configure
02:19what is the system idle mode?
02:21Well, the default is normal.
02:23There are two different modes.
02:24One is normal and one is keep awake.
02:26And there's actually short,
02:28there's basically strings for it
02:29that we could use basically the built-in static strings
02:35to get access to those static variables.
02:37I could, again, approach the system's idle mode.
02:40And again, instead of importing it,
02:41I could just type new system idle mode.
02:46By doing that, it's gonna automatically load
02:48my flash.desktop system idle mode,
02:50and I could delete that new
02:51because we really are not creating a new static anything,
02:54and we wanna select that keep awake.
02:56And that's literally all we really wanted to do
02:58and all we had to do to get our application
03:01to remain awake.
03:02Once we've added this line and we've saved it,
03:04once we actually run it and deploy our application,
03:07our application will not fall asleep anymore
03:10for as long as the application is open.
03:12So there you go.
03:13So now we got another feature added in
03:15and we're gonna test it.
03:16I'll test it out for another 30 minutes again
03:17and try to see if there's anything wrong,
03:19if there's anything that we need to add,
03:20and if everything is fine,
03:22then we'll move on to the next step
03:23of getting it actually into a store.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!