How To Upload Images To Firebase With Sketchware
Display video thumbnails in firebase chat
To upload and display video thumbnail in a firebase based chat in Sketchware, follow the steps given below.
1. On the chat page add a file picker to pick files (mime type */*).
2. Add an ImageView imageview1 for picking files.
3. In imageview1 onClick result use file picker to pick files.
iv. Create a String variable path.
v. In file picker onFilesPicked result, set up Cord path to the path of the file selected.
6. In the event of button1 onClick (send button), if String path is not empty, upload the file to Firebase storage.
vii. Add a Cord variable thumb_String.
8. In the event Firebase storage onUpload success, if the file selected is a video, create thumbnail from the path, convert it to base64 String, and send the url of the video (using cardinal "attachment") and the thumbnail in String class (using key "thumbnail")
to firebaseDb.
The code used here is:
Bitmap bitmap =ThumbnailUtils.createVideoThumbnail(path, android.provider.MediaStore.Video.Thumbnails.FULL_SCREEN_KIND);
coffee.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = stream.toByteArray();
thumb_String = android.util.Base64.encodeToString(byteArray, android.util.Base64.DEFAULT);
ix. In the effect onChildAdded, get the data to a List Map map1, and prepare information technology equally CustomView data for ListView.
x. In the CustomView of the ListView, add an ImageView thumbs.
11. In onBindCustomView, if the List Map map1 contains primal 'attachment', and the value of key 'attachment' contains .mp4 or .3gp,
then if the List Map contains primal 'thumbnail', get the thumbnail and display it in ImageView 'thumbs' using following code.
byte[] imageBytes = android.util.Base64.decode(
map1.go(_position).get("thumbnail").toString(), android.util.Base64.DEFAULT);
Bitmap decodedImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
thumbs.setImageBitmap(decodedImage);
Else if the key 'thumbnail' is not there, brandish a custom image as epitome of ImageView thumbs. See image below.
thumbs.setImageResource(R.drawable.black_vid);
Add together onClick block for ImageView thumbs. Hither utilise Intent to move to activity containing VideoView. See epitome below.
12. Save and run the project.
Popular posts from this blog
A Flash Light App in Sketchware
To create a Torch Flashlight awarding for Android with Sketchware follow the steps given below. i. Create a new project in Sketchware. In VIEW area add together an ImageView imageview1 . Set information technology's width and height to 100, and scale type to FIT_XY. 2. Using Epitome Manager add 2 images ic_flash_on_black and ic_flash_off_black . 3. Ready ic_flash_off_black as the image of imageview1. 4. In Library managing director switch on AppCompat and Blueprint . five. Add a Photographic camera component . 6. Add together two Boolean variables: flashLightStatus and hasCameraFlash . 7. Add two More Blocks: flashLightOn and flashLightOff . 8. In onCreate result, utilise add together source directly block and put post-obit code: hasCameraFlash = getPackageManager(). hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); nine. In More Cake flashLightOn , use add source directly block and put following lawmaking: android.hardware.camera2.CameraManager cameraManager = (android.hardware.camera2.CameraManager) getSystemS
Firebase auth in Sketchware for Login Activity
To create a login action using Firebase Auth in Sketchware, follow the steps given below. This method uses Firebase authentication service for creating login. 1. In your Firebase business relationship, become to Firebase hallmark. two. In Firebase hallmark web set up-upward, go to SIGN-IN method, and enable Email/password and Bearding. 3. Go to Project settings in your Firebase project and re-create the Web API Key, Project ID, and App ID. 4. Paste the Project ID, App ID, and Web API Primal in your project in Sketchware, in the Firebase settings. five. On the MainActivity folio add a File Shared preferences component user:user and an Intent i . Also add together a Timer t and a Firebase Auth testlogin . 6. Create a new page login.xml with Activity called LoginActivity . vii. In onCreate event of MainActivity use blocks every bit shown in image below. It identifies chief page with File user key page . It also checks if user is logged in to FirebaseAuth . If user is logged in then othe
Create a PDF reader android App in Sketchware
To create a elementary pdf reader in Sketchware follow the instructions given below. 1. Create a new project in Sketchware and create a VIEW every bit shown in paradigm below: linear2 : A LinearH for the buttons/tools. linear3 : A LinearV for displaying images. Set it's padding to 0. button1 : A Button for picking PDF files. edittext1 : An EditText for displaying the page number. Set up it's input blazon to numberSigned . textview4 : A TextView for displaying full number of pages. textview3 : A Push to move to page number entered in edittext1. textview1 : A Push button to move to previous page. textview2 : A Button to movement to next folio. ii. Remove Toolbar and Status Bar of this View to brand it full screen. 3. Add a File Picker component file_picker: awarding/pdf . 4. Add two number variables page and pageCount , and a Cord variable pdfFile . Besides add together a String list. 5. Add two more blocks: extra and brandish page(i) . six. In onCreate issue employ add together s
Unproblematic car racing android game in Sketchware
To create a simple auto racing game in sketchware follow the steps given below. ane. Create a new project in Sketchware. 2. In VIEW surface area of main.xml add a TextView textview3 for displaying score of previous game, a TextView textview4 for displaying high score, and a Button button1 for starting game. 3. In MainActivity , add a Shared Preferences component sp:sp . 4. Add onStart event and put blocks to set the text of textview3 and textview4 . five. Create a new page page2.xml . 6. On button1 click employ intent to motility to page2 . 7. On page2.xml add a LinearV linear1 with padding 0 and width and height MATCH_PARENT. 8. In Page2Activity , add a Shared Preferences component sp:sp . 9. Create a number variable highscore . 10. In onCreate outcome of Page2Activity , use blocks to set the value of number variable highscore , and employ codes to create a new GameView and add information technology to linear1 , as shown in image beneath. The lawmaking used in the add source directly bloc
How to enable upload from webview in Sketchware?
At present that Sketchware has a block to add java lawmaking directly in the projection, it is possible to enable file upload in webview. To enable file upload in webview in sketchware app, follow the steps given below. ane. Insert a webview in VIEW area in the sketchware projection. Note the ID of webview, usually it is webview1 . 2. In LOGIC area of project, in onCreate event, add together the cake add source directly and copy the following code in information technology: webview1.setWebChromeClient(new WebChromeClient() { // For 3.0+ Devices protected void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } // For Lollipop 5.0+ Devices public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChoose
Source: http://www.sketchwarehelp.com/2020/05/display-video-thumbnails-in-firebase.html
Posted by: johnsonfrony1967.blogspot.com
0 Response to "How To Upload Images To Firebase With Sketchware"
Post a Comment