Receiving SMS messages into your app (Android)

You can now receive incoming SMS messages (text messages) on Android devices, using the sms-receive plugin.

It does not intercept them – the messages still go to the Messages app. It only works if your app is compiled under PhoneGap.

Your app doesn’t have to be in the foreground – it will received the messages so long as it has been started. The received message is available as variable in your app – so you can use it to update databases, inform the user or all kinds of things.

Full details are in this Tech Note:

Android Web Apps: SplashScreens and Icons

Due to changes in Android OS, this post is deprecated starting with AppStudio 6.

Splash screen support for Android Home screen apps was added in Chrome 47, released in December 2015. It gives your web apps a look much more like a native app at startup.

There are a few new items in Project Properties for this. They are grouped together under the ‘WebApp Chrome’ heading.
Continue reading “Android Web Apps: SplashScreens and Icons”

Locking screen orientation on Android

Chrome 28 and higher now supports setting the orientation in your app. Simply do the following:


The screen will then shift to the orientation you specify and ignore the actual orientation of the device.

This only works on Chrome. If you try to execute this code on an iPhone, it will get an error and the orientation will not be affected. To improve the code above so it runs without errors, do the following:

If screen.orientation <> undefined Then
End If

The screen orientation still won’t change on an iPhone, but at least there won’t be an error!

A handy little Chrome trick: FullScreen

Google recently added a little trick to Chrome, allowing apps to become full screen. It works on both the Desktop and Android devices. You’ll need to be running Chrome Version 32 or newer.

To use it, add a button to your app with the following code:

Function btnChrome_onclick()
End Function

After going to full screen, a message is displayed telling how to go back: swipe down on an Android device or hit escape on the desktop.
As of Chrome 32, this is no longer needed.

Here’s how it looks on an Android device.

If you want to execute some code after the resize (perhaps to move controls to take advantage of the larger screen, do the following:

Function window_onresize()
  Print "resize"
  '… do any housekeeping
End Function

If you want hide the button if you are not using Chrome, add this code to your global code:

  If Not Then btnChrome.hide()

A few gotchas:

  • This won’t work with the Android Browser or iOS.
  • This won’t work with PhoneGap, as long as it still uses the Android Browser.
  • It seems to have to be done from a button: just putting it in Global Code does not work.

Let us know if you find out anything more about this trick!

Use Dropbox to quickly install .apk files

Want a quick way to get an App Studio app compiled with PhoneGap onto your Android device? Use Dropbox!

  1. Build your app using PhoneGap as always.
  2. Put the resulting .apk file into your DropBox. (Get an account if you don’t already have one – it’s free!)
  3. Install the Dropbox app on your Android device if you have not done so already.
  4. Open Dropbox on the device and click on your .apk file. It will install!

(If you have not used Dropbox yet, it’s a great tool. It puts what looks like an ordinary folder on your PC or Mac desktop. You can share it with other users and computers: add a file to your Dropbox and your other computers can use it right away. There’s lots more, but this already is the simplest network share you have ever experienced. Installation is also very simple.)

PhoneGap 1.0 released!

PhoneGap has announced that Version 1.0 is now available. The release puts the focus on accessing native device APIs, which is new ground for the web. Other improvements include:
* Overall API stability and “pluggable” architecture
* W3C DAP API compatibility
* Contacts API
* Remote debugging tools
Today’s release also includes a new unifying bridge interface that makes adding platforms and platform extensions easy. Plus, developers will be pleased to see that the plugin development process has been simplified.

PhoneGap lets NS Basic/App Studio users package their apps for iOS, Android and other app stores. It also gives them additional API functions.

The easiest way to make use of PhoneGap is with PhoneGap Build. There is also a tutorial on using PhoneGap Build.

Here are some other NS Basic + PhoneGap resources:

NS Basic/App Studio and PhoneGap

The most important feature of NS Basic/App Studio 1.1 is support for PhoneGap.

PhoneGap is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores. It takes your NS Basic/App Studio app and packages it so that it is acceptable for Apple’s App Store, Google’s Marketplace and other platforms.
It also provides additional API functions not found in NS Basic/App Studio.

Depending on platform, these can include:

  • Compass
  • Camera
  • Contacts
  • Files
  • System Information

PhoneGap is free.

Here are a couple of tutorials to help you get started.

Distributing apps using PhoneGap is much more complex than webapps. Android/PhoneGap has a complex installation procedure. While iOS is easier to get going, the 4+ gigabyte download and the complications of the App Store make it at least as complex an undertaking.