AppInventor: HOW TO: Turn your AI2 app into a Voice Activated App (Google Now)

Leading on from my initial enquiry here:

Using Google Now on your Android phone you can start several “Google” apps with voice commands.
It is possible to convert your AI2 app for the same thing. For the purposes of this howto:
The apk filename is  MyVoiceApp.apk
The appname is “My Voice App”   << what you see in the App Name on Screen 1 Designer
1. What you will need:
  • A PC
  • apktool (Windows/Linux) or AppToMarket (Windows)
  • Your apk file
2. Decode your apk using your preferred decoder/encoder
3. Browse to the res folder in the decoded apk and create a new folder called xml
 
4. Browse into the xml folder you have just created and create a new text file called searchable.xml
 
5. Open up searchable.xml and copy and paste this into it:

 

whilst replacing “My Voice App” with the appname of your app

Save searchable.xml.
6. In the root folder of your expanded apk, find the file “AndroidManifest.xml” and open it with your preferred text editor.
It may look something like this:  (the apkfilename and the appname should be correct in this file and match that of your apk)

 

7. You now need to add a new intent filter section and some configuration lines. Do this just above the <intent-filter> line

This is what you should add:
           

 

and your resultant AndroidManifest.xml file should then look like this:

 

Once this is done, save AndroidManifest.xml, and your work on editing the apk is done!

8. Now re-encode your apk using your preferred encoder/decoder, deal with the signing and zip aligning of apk as needed.
Sideload you new apk onto your device
Get Google Now running and ask it to: “run ‘My Voice App'” or “start ‘My Voice App'”  (both seem to work for different things???)
Your app should open up from closed or in the background.
If you need help with how to use apktool, just ask.
Tim
Credits due to the original poster on techrepublic here

AppInventor: HOWTO: Upload Image to Google Drive using base64 and Google Apps Script Web App

This question was asked on the forum recently, and due to changes in google authentication has become more difficult to achieve. However, by using a “man in the middle” web app, it is possible to upload images to a private or public google drive folder, using base64 to convert the image to a string, and back again!

Credits must go to TANAIKE whose blog post on achieving this in several different ways, primarily using curl from a command line, lead me to a solution, and also to ghostfox for the base64 conversion extension over on thunkable.
I used the imagePicker to select files for upload, as this provides a full path to the file. It doesn’t have to be done this way. To upload image assets in your app for the base64 extension, one must first copy the image to the internal sdcard.
To wet your whistle, here is a video of a sample app in action:
You are going to need three elements for all this to work (assuming you already have a google account in place!):
  1. A google drive folder to upload your files to, along with the ID for that folder
  2. A google apps script web app to handle the decoding of the base64 string
  3. An AI2 app to select and upload the file from
Lets get started
1. Google Drive Folder
Create a google drive folder for your uploads.
Note the folder ID
Decide on sharing options for your folder
2. Google Apps Script Web App
Somewhere else in your google drive, create a new Google Apps Script and name it accordingly
In the already created code.gs add the following code, overwriting the default code

Replace FOLDER ID HERE with your chosen folder ID
Save the project and the publish as a web app, running the app as you, and available to anyone.
You should be asked to authorise permissions, do so. If you are not asked then select the doGet() function and run this to get permissions sorted
You will also get a popup telling you the url to your published app (the one in the box). Note this down as you will need this for your AI2 app.
The web app requires three parameters: a filename, a file type, and the file itself ( in this case the base64 string )
3. AI2 App
These are the blocks used in the sample app from the video.
The only item you need to edit for it to work is the value for Web1.Url in the Button.click event. This is the url to the web app created earlier.

NOTE: after writing this howto, I discovered that some devices, or devices in some locales will convert jpeg extensions to jpg, and others from jpg extensions to jpeg

If when your image is selected by the listpicker and comes through as jpeg please change your ImagePicker1.AfterPicking blocks to the following: (and additional if statement to account for the jpeg extension

You should now have everything you need to upload files to google drive :)

aia attached :) uploadImage2GoogleDrive

AppInventor: HOWTO: Dynamic Scrolling Image List with Titles using webviewer (with select)

Been working on this for a while, time to share the fruits of my labours!
There are many different ways to achieve much the same thing, but I wanted to have a go at building things up from scratch, just use pure javascript, and provide some user functionality in the process.
Youtube video to start things off:
How it works:
The Ai2 blocks feed the html file with all the data: image files, file locations, titles and subtitles, shape of image (square/circle), colour scheme.
The html file pulls all this information in through the webviewstring, and then by creating arrays from the webviewstring, dynamically builds a “card” for each image.
Note the use of classes from the w3.css and w3mobile.css to assist with the cards layout
A click on the image returns the file to the AI2 app and displays it.
Developers can choose to set all the variables to their liking, or can also provide a settings area for the user to do likewise (further demo hopefully coming on this!)
A couple of Taifun’s wonderful extensions used.
BLOCKS
HTML

aia attached :)  ImagePicker2