Posts

Showing posts from August, 2018

A Flash Light App in Sketchware

Image
To create a Torch Flashlight application for Android with Sketchware follow the steps given below. 1. Create a new project in Sketchware. In VIEW area add an ImageView imageview1 . Set it's width and height to 100, and scale type to FIT_XY. 2. Using Image Manager add two images  ic_flash_on_black  and  ic_flash_off_black . 3. Set  ic_flash_off_black  as the image of imageview1. 4. In Library manager switch on AppCompat and Design . 5. Add a Camera component . 6. Add two Boolean variables: flashLightStatus and hasCameraFlash . 7. Add two More Blocks: flashLightOn and flashLightOff . 8. In onCreate event, use add source directly block and put following code: hasCameraFlash = getPackageManager(). hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); 9. In More Block flashLightOn , use add source directly block and put following code: android.hardware.camera2.CameraManager cameraManager = (android.hardware.camera2.CameraManager) getSystemS

Display url source code or online text file in android TextView

Image
To display an online text file or source code of any web url, in a TextView, we have to do following: Create a URL object from the String representation. Use openStream() method to open a connection to this URL and and get the InputStream for reading from that connection. Create a new BufferedReader , using a new InputStreamReader with the URL input stream. Read the text, using readLine() method of BufferedReader. But this cannot be done directly in an android project because android apps do not allow networking operation on its main UI thread. Therefore we need to use AsyncTask class, which allows us to perform background operations and publish results on the UI thread. To create such an online text file reader app in sketchware, follow the steps given below: 1. Create a new project in Sketchware. In VIEW area add a LinearV inside a ScrollV. In this add an EditText edittext1  (for writing URL), a Button button1 , and a TextView textview1  (for displaying re

Speech Recognition: Speech to text in Sketchware

Image
We can implement Speech recognition using codes in add source directly block in Sketchware. Follow the steps below to implement Speech recognition in Sketchware. 1. Create a new android project in Sketchware. 2. In VIEW area add a Button button1 and an EditText edittext1 (or a TextView). 3. Add a new FilePicker component fp . 4. Add a new More Block extra . 5. To define this block extra , use an add source directly block and put following code in it: } public static final int REQ_CODE_SPEECH_INPUT = 1; { 6. In the event button1 onClick , use an add source directly block and put following code: Intent intent = new Intent(android.speech.RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(android.speech.RecognizerIntent.EXTRA_LANGUAGE_MODEL, android.speech.RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(android.speech.RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); intent.putExtra(android.speech.RecognizerIntent.EXTRA_PROMPT, "