Can App Inventor have a button or control that rotates on screen?

A reader asked: Is there is a way to have a control, such as a button, rotate on the screen?

With a simple trick, the answer is Yes!

The trick is to use ImageSprites that are made to look like buttons. Then, instead of .Click event handler, as used on a Button, we use one of the “touch” events defined for the ImageSprite class. To rotate the sprite, change the sprite’s Heading property. Easy!

If you would like to learn more about ImageSprites, please read my online tutorial “Using ImageSprites for animated App Inventor Graphics”.

I’ve also written an inexpensive 227 page e-book all about graphics, animation and charts available from many online e-book outlets. You may find that text helpful to you as well.

Tutorial Video

The tutorial is shown here as a video – or page down for a written version of the tutorial.

User View

Watch this video to see what a rotating button looks like:

Designer View

Creating the user interface is the same as creating other App Inventor user interfaces – except we use a graphical drawing area called the Canvas and add an ImageSprite to the Canvas.

Continue reading

Using droid-at-screen to see your phone’s display on your computer

droid-at-screen is a free Java-based app that displays the content of your phone’s display to your computer’s display, when the phone is connected via a USB cable.

Below is a screen snap shot taken from my computer display. At the upper left is the Droid@Screen application running.  Droid@Screen is connected to my Nexus 5 phone.

At right is the display showing on my phone, which has been transferred from the phone to my computer over a USB connection. I’ve circled two user interface items – the magnifying glass icon is used to adjust the display size of the phone’s screen. Since the phone has a 1920×1080 display, the initial image is quite large!

Below that is a camera icon. Click on that to take a snapshot of what is on the screen, and then save the screen image to a local file.

Capture

At the lower left is the DroidAtScreen .jar file. This is the Java executable program file. Assuming Java is installed on your system, double click the .jar file to begin running Droid@Screen.

Continue reading

Can you “gray out” a button until data entry is complete?

A reader asked  if it might be possible to “gray out” a button so that pressing it has no action, until appropriate data has been entered?

The answer is “Yes, we can do this.” After some thought, I came up with the following simple solution.

Update 1: Check the comments to this post for a reader’s great solution for doing this for Location services dependent function.

Update 2: Also, you can set the button component’s Enabled property to false, so that the button will not function. Then set Enabled to true once the data entry meets your app’s requirements.

User Interface

What we want to do is have the button look like it is “grayed out” and unusable until after some data is entered into the field. In the text box, I have set the  “hint” value to “Button available when data entered”:

Screenshot_20160317-202312After the user has entered some data, the button becomes “active” as shown here:

Screenshot_20160317-202334

Continue reading

Measuring Android Power Consumption

I did my software engineering Masters thesis (2012) on Android power management and I learned, as part of my research, that most app developers have no idea how much power their app demands from their Android device’s battery.  Some who thought they were looking at power were confusing other metrics with power. At the time, tools for measuring power were not easy to obtain (costly, and hard to measure power inside a phone).

Now there is an app that provides many metrics about what apps are doing on Android, including power.

Go to the Google Play store, search for Trepn Profiler and install that app (from Qualcomm, who makes the Snapdragon processor used in most phones).

For a quick look at battery power in a strip chart format, select Network Activity and see a chart like this:

Screenshot_20151102-160041

Then select CPU Usage Monitor and identify what percent of CPU time is being used by each app. Initially the display will show “No applications are running” – wait a moment and gradually, apps will begin to show up in the list, with the % of CPU core they are using, shown at right. This may help you spot apps that are using an unexpected amount of power.

If possible, delete apps that you never or rarely use. Many lurk in the background and periodically run a fraction of a second, infrequently. While each individual app has little impact, the total of all apps may start to have an impact that you notice.

For more information about Trepn and estimating power consumption, read the linked article, below.

Trepn Profiler

Source: How to Measure Power Consumption Using Free Software | Mostly-Tech

 

Can you make a video player in App Inventor? Not really, unfortunately.

A question from a reader: Can we make a video player in App Inventor?

The short answer is, unfortunately, not really.

In the App Inventor Designer, in the Palette’s Media section, you can drag a Video Player into the viewer. But this Video Player only plays video files (WMV, MP4) that are stored inside your app (not on the web) and these files are limited to just 1 megabyte in size. Therefore, the Video Player feature in App Inventor is so limited as to not be very useful for most applications.

 

Android battery life – and how to extend your battery power

When I had a Nexus 4 running Android 4.3 and earlier, I used an app called Juice Defender to extend the time between battery charging. I often went 2 days without recharging the battery!

But Juice Defender has not been updated since 2012 and due to Android changes, Juice Defender no longer works well.

Then, Android 5 resulted in worse battery life for many of us! My phone was discharging half the battery in 8 hours, even when not being used.

The only way to extend battery power is to reduce power demand. That means turning off hardware features that may not need to be used all the time (WiFi, Bluetooth, GPS location), dimming the screen or turning it off and so on. Another way to is reduce the frequency that apps wake up to “sync” or go online.

Good “Battery Saver” apps work by intelligently switching features off and reducing their frequency of use. Some battery saver apps are good and some are awful; in fact, some have displayed false battery status to pretend they are saving power! I have tried numerous Battery Savers but found only one that works effectively on the Nexus 5: Avast Battery Manager (see link below).

With that in mind, here are ideas that may help your device reduce its power demand and extend is battery life between charges:

  • Install Avast Battery Manager from Google Play. This works well for me using its “Automatic mode” settings. The app also provides information about which apps are consuming power on your phone. You may choose to stop, disable or uninstall apps that consume excess power.
  • Google Chrome and GMail apps are power hogs relative to other apps. It seems that if you visit a page, like a financial page, that periodically “auto refreshes” (e.g. for stock market data), this auto refresh may continue to occur periodically when you are not using the phone (this is my hypothesis – its not yet verified.) Avoid leaving Chrome on such pages, if you can. In GMail, go to the GMail menu (the one where you can select Inbox, Sent, Outbox, etc), scroll all the way to the bottom and choose Settings. For your GMail account, uncheck Sync GMail – and then manually resync GMail by swiping down from the top when you are using GMail. For POP3/IMAP email accounts (if any), set the sync time to 60 minutes (the longest option available) – or go to Settings | Accounts, select the email account, and turn off sync completely.
  • Many apps start up when your device is powered up and drain a small amount of power running in the background. Even if you never use the apps. Uninstall apps that you no longer use or you do not need.
  • Use Wi-Fi, if available, instead of cellular data. Generally, good Wi-Fi data links are much faster than cellular data, which means data can be uploaded or downloaded in less time. That means the transmitter (which uses more power) is active for less time, helping to reduce power. Further, due to some issues in how the cellular data protocol works, the cellular transmitter remains in an elevated power state for several seconds after being active for a data transmission. Related: While out and about and using only cellular data, turn off WiFi. You may also consider disabling Bluetooth and Location services.
  • If battery life seems to be getting worse, go to Settings | Storage, and scroll down to Cached data. Select “Cached data” and then follow the pop up menu to clear the cached memory. This is not something you do every day – but when the battery has gotten bad, taking this step every once in a while has significantly improved the battery power.
  • If you are using Avast, you can likely skip this step: Go to Settings | Battery and click on the 3 vertical buttons at upper right. Then click on Battery Saver and set this to “On”. Normally, Android’s own battery saver only activates when the battery is very low, but you can activate it manually. This built in Battery Saver reduces app data synchronization with the network, disables location services and does a few other things to reduce power. The Battery Saver is automatically turned off and remains off, once you plug in to a charger.
  • Aggressive: Set your device to Airplane mode. This turns off all built in radios and suspends background apps from doing data communications. Again, if using Avast, you are already getting good power management and this step adds only a little to the battery life. And while its activated, you cannot receive voice or text messages either!

Hopefully these suggestions are helpful to you!

Part 2: Sending numeric data using App Inventor Bluetooth communications

Part 1 of this tutorial introduced Bluetooth communications and implemented a simple method of sending text data back and forth between two Android devices over the Bluetooth wireless link. If you are not familiar with using App Inventor’s Bluetooth component, start with Part 1.

In Part 2, a data packet concept is introduced to guide the communications between devices, and is used to send a combination of text and numeric data. This section introduces the concept of binary numbers so that you can understand why we would handle text and numbers in different ways.

This tutorial modifies the user interface of both the client and server programs introduced in Part 1. Then, blocks code is added to send text and numeric data. Numeric data is sent as binary data using special methods of the Bluetooth components.

Related:

Related:

Continue reading

Blocks Editing Tip: Arranging and collapsing blocks in the editor

As you develop your App Inventor program using the Blocks editor, do you find your blocks overlapping and crashing in to one another on the screen? You know, like this:

AIBlockMess

You can drag the blocks on the screen so they no longer overlap, but dragging each block is tedious (time consuming). But there is an easy way to automatically re-arrange the blocks.

  • Move the mouse pointer to any part of the white space outside the blocks
  • On Windows, right-click the mouse button
  • On Mac OS X, press Ctrl and click the mouse button

Continue reading

Update: Reading and writing text files with App Inventor

I previously posted a short tutorial on writing to and reading from text files stored on an Android device, using an App Inventor app.

Unfortunately, as some comments noted, the file being created seems to disappear – the data is written and can be read back – but the file is no where to be found on the phone!

After some research, I now know where the file is – and also how to copy the file from the phone (or tablet) to your personal computer.  While the solution to finding and saving the file to your computer is ultimately easy, I need to update the tutorial and explain some things about the Android file system. You will also need to install a free app on your phone in order to copy the file to your computer.

I have posted an updated tutorial that explains the details and shows how to store your files in the right location, how to find them (they are hidden from most views), and how to copy them to your personal computer.