Posts

Limiting text length of Edittext in Sketchware

Image
If you want the user to provide only a certain type of text input in the Edittext field, it can easily be done by selecting appropriate option for input_type from text properties. The image below shows the input_type options: However, maxLength or any other option to limit length of input text, is not available in Sketchware. Which means you have to use code blocks in Logic area. To limit the input text length (suppose to 7 characters), in Edittext: edittext1  apply InputFilter to the EditText field. In onCreate event, use an add source directly block and put following codes: InputFilter[] filterArray = new InputFilter[1]; filterArray[0] = new InputFilter.LengthFilter(7); edittext1.setFilters(filterArray); This will limit the input text length to the first 7 characters. With this method, if any extra character is entered at the end, it doesn't appear. If there are 7 characters in the EditText field you cannot add more characters.

How to get apk file or source code of your Sketchware App

Image
1. In the list of your projects click on the options symbol next to project for which you want source code or apk file. 2. From the options select Sign/Export . Here if you are not subscribed to Sketchware, you will be required to watch a video Ad. Then it will show a screen with 3 options: Sign APK , Source Data for Sketchware , and Source Code for Android Studio . 3. To export apk click on Sign apk button. It will compile the project and sign the apk, and save the signed apk in /sketchware/signed_apk/ folder. 4. To export source code click on Export Source Code button. It will save the source code of the project in  /sketchware/export_src/  folder as a zipped file. The source code is a zipped file containing all the files and folders of the project, which can be edited and recompiled using other Android IDE softwares like Android Studio.

How to use soundpool in Sketchware?

Image
The soundpool component is used to play sounds of smaller duration in android apps and a single soundpool component can be used to play multiple sounds. Now suppose you have three sounds which you want to use in a game at different instances. To use the sounds follow the steps given below. 1. Open the Sketchware project in which you want to use the sounds. Go to sound manager and add the three sounds which you want to use. 2. Now add a soundpool component (named ' sounds ' in the image below) in the Logic section of your app. 3. After this go to onCreate event and add a number variable (named sound in the image below). 4. Then in onCreate event, first use the block: SoundPool (name) create max stream count....  Since here three sounds are being used set max stream count to 3. After that use SoundID:SoundPool (name) load (sound name) and set the number variable to load the three sounds one by one, as shown in the image below. This will set the SoundID of...

Android App: Let people find your shop on map

Image
In android a button or any other event can be set to open a particular location in Google Maps app, with the use of Intent. Suppose you have an Android app for your shop or organization developed in Sketchware, and you want people to reach you. You can provide your address to the app users but a location on maps is always better and preferable. Below is a description of how to link to Google Maps from an android app created in Sketchware. For this Google maps app is a prerequisite and if your user do not have it installed on their device, they may not be able to locate your address on map. Step 1. Download Sketchware App, and create an app for your shop. Insert a button which says 'Locate us' or 'Reach us'. Step 2. Add a new Intent component and name it as share . Step 3. Open Google Maps app. Find Your shop and copy it's coordinates .  Or copy share URL for your address. Step 4. In button onClick event, use blocks as shown below to link your app...

Creating a Quiz Android App

Image
This is a tutorial on creating a quiz in Android. After this tutorial you will be able to create your own Android App with your own quiz. Follow the instructions given below to learn how to create a quiz app in Android. 1. Download Sketchware App for Android devices. 2. Open Sketchware and start a new project. Enter the app name and other details as per your wishes and click save. 3. Now in the View area (main.xml), insert a Scroll(V) and inside that a Linear(V) . Set the width of both the Layouts to match parent and set the padding of Scroll(V) to 0. Also set the background color of Linear(V) to green or a color of your choice, and gravity of Linear(V) to center_horizontal, center_vertical. 4. Now insert 4 button widgets (depends on your requirement), one each for each of the quiz. Each quiz can have several questions. Rename the buttons as Quiz1, Quiz2, Quiz3 and Quiz4 respectively. Now for each of the buttons: increase font size to 18, set margin of each to 8,...

Difference between setVisible_INVISIBLE and setVisible_GONE

Image
Though both setVisible INVISIBLE and setVisible GONE appear to achieve similar tasks, but both are different. With setVisible INVISIBLE object remains on screen but is not seen. Whereas with setVisible GONE, object disappears from screen. Here is an illustration. Suppose there are six imageviews arranged horizontally inside a linear horizontal as shown below. Now in the Logic section, if the fourth image is set VISIBLE and rest of the images are set INVISIBLE, the fourth image will be visible at it's position and rest of the images will disappear, as shown in the image below. Whereas if the fourth image is set VISIBLE and rest of the images are set GONE, all other images will disappear and fourth image will shift to left to occupy the initial available space on left side, as shown in the image below. It appears to be a simple difference but it is important to be aware of this as it can be useful in fixing many bugs in android games and apps.

Use of Intent to share text and links

Image
The text from Edittext fields and from Textview fields can be shared from the App using Intent. Here are the Logic blocks to be used for the purpose. 1. To share text to WhatsApp Intent  (name)  setAction   ACTION_VIEW Intent  (name)  setData   join whatsapp ://send?text= and (Edittext/Textview) getText StartActivity  (name) 2. To share text to Twitter Intent  (name)  setAction   ACTION_VIEW Intent  (name)  setData join  http ://twitter.com/share?text= and (Edittext/Textview) getText StartActivity  (name) 3. To share text on Facebook Intent  (name)  setAction   ACTION_VIEW Intent  (name)  setData join   https://www.facebook.com/sharer.php?u=[URL]&t= and  (Edittext/Textview) getText StartActivity  (name) 4. To share on Google plus Intent  (name)  setAction   ACTION_VIEW Intent  (name)  setData join ...

Use of Intent to Mail, SMS, MMS and Call

Image
In Sketchware, the uses of Intent activity are limited as it contains only three setAction options: ACTION_VIEW, ACTION_DIAL, and ACTION_CALL. Here I mention the logic/codes for a few uses of Intent. 1. Open a Url in mobile browser. Intent (name) setAction ACTION_VIEW Intent (name) setData http:// xyz.com StartActivity (name) 2. Open mobile contacts. Intent  (name)  setAction   ACTION_VIEW Intent  (name)  setData   content://contacts/people/ StartActivity  (name) 3. Open mobile dialer. Intent  (name)  setAction   ACTION_DIAL Intent  (name)  setData   tel: 894...... StartActivity  (name) Also, Intent  (name)  setAction   ACTION_VIEW Intent  (name)  setData   tel: 894...... StartActivity  (name) 4. Call a number. Intent  (name)  setAction   ACTION_CALL Intent  (name)  setData   tel: 894...... StartActivity ...

How to create a new screen and link to it in Sketchware

Image
To link to a new screen in your Sketchware App, follow the instructions given below: 1. Click on main.xml at left bottom of screen and click on add symbol to add a new View. 2. Give a name to your new screen ( View name ). 3. Next add a new Intent component.  4. Use Intent setScreen and Start Activity blocks in the event when you want to open a new screen.