2017년 8월 22일 화요일

JOIN block type


I am trying to create the No Texting While Driving app in Chapter 4 of the AppInventor2 book and am having a problem.  In the Text to speech portion, it shows using a JOIN block to string together a phrase and the phone number and a phrase and what the actual message is.  However, in the text drawer where the JOIN block is, there is no JOIN block with four plug in slots, just two.  I have joined a couple of JOIN blocks together (picture below) will this work or am I just missing something?



--
See that fancy blue square on the JOIN boxes? Click on that.
Then drag the "STRING" block from the left of that menu into the JOIN block on the right of that menu.


--

join


how to i join many join tabs eg 50 when my screen is not bigger enough

--
Do it in steps. And you knew that by pressing on the blue square you can drag more items into the join?
See for example here: JOIN block type
--
Join half in one temp variable, then join the rest to that variable. You can also right click on the join block and select inline input.

--
how to i join many join tabs eg 50
Put the things you want to join into a list,
run the list through a list to csv block,
then through a replace comma with empty string block.

What kind of app needs a piece of text built from 50 pieces?

--
to send a sms results with 50 or so outputs 

--
to send a sms results with 50 or so output
I haven't used sms yet, but doesn't it limit its messages to 140 (or so) characters?

Are all these 50 results only 1 or 2 characters each?

This sounds more like a Fusion Tables operation.
If you haven't done so yet, do the Pizza Party tutorial.

--
to send a sms results with 50  or so outputeg like this 


--
Do as Abraham says, put it in a list and join the output by going through the list.

List Blocks, by Sajal Dutta: List Blocks On App Inventor

Chapter 19 of the App Inventor book:
http://www.appinventor.org/bookChapters/chapter19.pdf

Displaying a list: Displaying a List

--

Bluetooth 4.0, smart bluetooth, bluetooth low energy


Is it possible to make an application in App Inventor, which can communicate with BLE(bluetooth low energy) enabled devices?

--
Currently we only support Classic Bluetooth, but not BLE. I will add this to our list of issue, features and updates to investigate. For information on App Inventors Bluetooth component is our documentation here.

Any update when Bluetooth 4.0 will be developed? I need this for an upcoming project. Thank you!

--
There are no plans to develop this any time soon.
If you really need it and are willing to work on it, we'd be happy to
help out and integrate it in AI. Please join the open source group if
you want to get started:
http://appinventor.mit.edu/appinventor-sources/

--
Would be great if you could support BLE (Bluetooth 4.0) it is the future and an interface on this platform would create the opertunitiy for many developers to base thir design on it and expand it . Pls prioritize . lets be first not last to utilize this new geat technology . thanks

--
I urge you to prioritise BLE higher.

There is a lot happening around BLE and Android.

Different sensors the iBeacon just to mention two areas where BLE is exploding. To be able to create sensors that can be powered with a coin battery for years is cool and opens up a lot of areas that hasn't been available before.

I'm using App Inventor both in learning and teaching programming and for my own small test/demo apps.

So from a non programmer view, it would be highly appreciated.

--
I totally agree with Mats on this subject. Technology with BLE is about to bloom quickly especially with the advances in wearable technology. App inventor allows us non-programmers to create great programs with very little time and is an excellent tool! If their needs to be funding to push this then do so, I guarantee you will receive it.

--
Funding is always welcome, if you have any leads, please do share.

The other options is that someone out there with programming knowledge
is interested enough to contribute this through the open source
community. All info here:
http://appinventor.mit.edu/appinventor-sources/

--
I can contribute with project management and BLE 10 000' BLE knowledge and testing.

Programming knowledge isn't my cup of tea, sadly...

So what else can I do to make it happen ? (I will read through the source to see if I can comprehend what amount of work it is)

And to set a goal, BLE is kind of a wide goal, can it be narrowed down to a part of BLE?!

--
Get in touch with the open source group; if you can convince anyone in there with the programming chops to do this well, we'd be delighted to help with AI questions and go ahead with the project. You can find more info about the sources at: http://appinventor.mit.edu/appinventor-sources/

--

Need help for an application using bluetooth


I am making an application for drive a test bench by bluetooth , so i send commands to the bench like for change the frequency (#F?) and he will answer for example 28 hz to the right label .
You can see the appli and blocks attached.

The problem is when i get the answer for the bench like (28) hz i see on the right label not 28 but 2... and 1 second later ...8.. but i want 28, he dont save the first number ! i dont know how to do.

The other problem is : i want the see all data on one label (label 11) (a terminal we can see it at the end of the application)  its to know if the command is send to the bench.


--
You should post your sketch so we can see how you are transmitting the data from the other end.

Your symptoms are usually relieved by adding a Delimiter like LF to the end of the messages coming in to AI2,
by using the println() command to send each message, and making three changes to the AI2 side:

Set the Designer BlueTooth Client Delimiter to 10
(10 is decimal for LF)

Use a two-layer IF/THEN test in your Clock Timer:
IF Connected THEN
  IF Bytes Available > 0 THEN
     (only ask for data if it's available)

Have the inner BlueTooth Receive Text ask for -1 bytes,
to get only complete messages.

Regarding the relative transmission and reception speeds,
try not to have either side drink from a firehose.

--
Hello,
I tried to do the modification of the program, but he doesn't work , you can see it on attached file.

--
See this post's attachments for how to do it right. info for app arduino/android communication

You had two serious errors in your code,
setting the delimiter in the wrong place and
not requesting number of bytes = -1 bytes.

--
I did like the other guys on your link, but it doesn't work can you see what is wrong on my .aia pls.


--
Post your blocks image, please.

--
I finally got a chance to import your .aia file (after helping all the other people who posted 
easier to debug screen shots for express service).

The only thing I noticed that might be a problem was the inclusion
of an extra clock, Clock2, always firing for no reason.
I suggest removing it in the Designer.

I don't see your latest C code from the other side, so I
can't tell if the markers you check for in the incoming text
are being transmitted from the other side of the connection.

For complete diagnosis, I suggest adding temporary labels
to your AI2 design and updating them with the incoming message
and the number of available bytes.

Also post your C code.

--

App Inventor 2 - Front Camera Project


The Problem
We currently provide a property in the Camera component to use the front camera if needed.


It has been reported as not working on certain devices.


The Camera component code shows the current implementation using an extra field in the camera Intent:


     if (useFront) {
       intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
     }


This does not seem to be working anymore, at least on newer phones, and we need to change this as soon as possible.


Working on this project

Prerequisites

1) You are familiar with Java and the Android SDK.
2) You are familiar with the App Inventor codebase.
Make sure you fork the project, and work in a feature branch; we have slides for that: Contributing to App Inventor through github, and App Inventor development workflow.


In fact, there is a full course for App Inventor development here.

Workflow

1) Reproducing: Make sure the function does not work anymore (as reported). If it works for you, contact us anyway as explained in step 2.


2) Communicating: Talk to us! We want to know you are interested in working on this. Talk to us on irc (if there’s anyone there: freenode #appinventor) or start (reply to) a thread in the Open Source forum.


3) Working with the Camera: We always recommend to work with the Android SDK before working with the App Inventor sources. It’s generally a lot faster to work with Eclipse or Android Studio than it is to compile the full AI codebase.


Play with camera functions in an Android SDK app as explained at: http://developer.android.com/guide/topics/media/camera.html
Note that some of these methods are only available in API level 9. At the moment we support API level 3, but while you are working with the SDK, you should explore all the functions available in there (more information on this later).


You should also have a look at how we have created the Camera component. You will see there that we have used an intent to use the built-in camera app (a different implementation might be possible).


4) Proposal document: Now that you have an idea of how things work, you should write a brief design document and share it in the open source forum to get feedback before you start coding on App Inventor. Search the open source forum for other design documents; there’s plenty of examples there! (two examples: blocks filter proposal, Player fixes).


After a quick look at the camera docs, my feeling is that we should use Camera.CameraInfo to detect cameras, and open the front one if the property is selected (and the camera exists). I might be wrong with this, and also note that CameraInfo is an API level 9 function. You will probably come up with a better solution!


5) App Inventor coding: now it’s time to place your code or fixes into the AI codebase. Make sure you follow the guidelines in supporting older and newer devices in App Inventor to make the change compatible with older devices. There might not be a way around not having some functions on older devices, and that is fine as long as we handle those devices properly (and we send feedback to the user of the app).


Make sure you have gone through the main documents for adding components and properties.


6) test; test; test: When you think you are ready for a review, you can open a pull request (review the workflow slides). Make sure you pull again from our master and rebase your code, as this will make our lives easier and we can review your code faster.


When you open your pull request, your design proposal should briefly document any changes that you have made since you first started working on the project (design changes) and also the URL for an appspot instance with your changes deployed; make sure you include a link to a Companion app if your changes affect the currently existing one.


What happens next?

Please note that this is supposed to be a rather interactive experience. We want you to talk to us through the open source forum as soon as you decide to start looking into this, and to keep talking to us throughout the process.


Once you open a pull request, we will look at it on github; we will probably go back and forth with you there until we are all happy with the code. But that’s a rather light review. Right after that, we will push your code for internal review, and we will take a bit longer to provide feedback and make sure that everything is good for a merge. Once internal review passes, your code is automatically merged and will show up in github.
For internal review we will squash all your commits into one (that’s how the internal review server we use (Gerrit) likes things done). So once your code is merged, it will appear as a single commit, even if you made a number of commits in your feature branch.


Any questions?

Please get in touch through the open source forum.



Help with project fix - Front camera


it's been reported in the forum that the front camera property has
stopped working. We are looking for help on fixing this and we've put
together the following document explaining the work needed: App Inventor 2 - Front Camera Project

Please have a look and let us know if you are interested in coming up
with a solution!

We are also interested in knowing if this is a good model to get
contributions from you guys; do you like the idea of having this kind
of 'mentored' projects? If so, we will spend a bit of time documenting
more of these and will add a section to the OSS site with a list of
potential projects to work on.

--
The front-camera option depends on an undocumented feature of android that is included for "testing." Not using a real api means there was never a google promise of it working for any amount of time in the future, and the feature of app inventor carried that uncertainty. 

It not working on a per-phone basis is new to me, but I totally don't doubt it. 

When it fails, it fails cleanly, and the default camera opens up.

I wrote this feature, and that's my line of code in the doc.

So what do we want to do?

--
Mark, it was working on my phone when I used it in the past, but it's
not working anymore. There's a proposed solution in the doc, but I'm
sure it's not the only one possible.

--
Just tested, and it's exactly as i thought: no longer works on my 4.4.2 Nexus4, but does still work on my 4.3 samsung.

It worked as of 4.4.whateverTheFirstVersionPushedWas

I re-checked the documentation, and it appears the correct answer is to build a camera feature proper, using the android Camera API, rather than an intent off to the camera app. 
The barcode reader is already embedded, which uses the raw camera api, so it's not terribly far-fetched. 

Multiple camera support starts at API level 9, and would, if done well, also allow the App Inventor component to query what cameras are available on the device. 

This solution is not something i'm ready to devote time to doing. I see no way to get around it, with or without intents, now that google has closed that door. 

So yes, José, your proposal is basically right, to use the Camera API to query the abilities of the device, but it can't simply be added to the current intent-based mechanism, as the intents don't support camera choice (as of right now, officially as of never). The whole core of the camera AI component would need to be rewritten.

But, as is always said, I could be wrong.

---
The camera and video component were 2 component on my to do list for my own mods. A few months ago I created a experimental app to control the camera and preview the image in a surfaceView and switch between the front and rear camera which was pretty easy to do. My plan was to redevelop/redesign both components from the ground up and also include a surface view to give live feed back rather than using the built in camera app.
The only issue as Mark has already stated is the to access the front camera with the Camera API you have to set the targetSDK level to 9 and I know for MIT App Inventor this would not work as you are running on API 3.

I have done a lot of searching on the net today to check if there is an alternate way to check for a front camera on API 3 and so far haven't found a solution as yet. I will keep search and try to think of a way to solve the issue but I have the feeling the only way to do this will be if the targetSDK is 9 unfortunately

--
Gareth, level 9 functionality is fine as long as we provide less
functionality or proper handling of older devices: Supporting older and newer devices in App Inventor

--
Setting target to 9 will drastically affect all layouts

--
I am not proposing changing the min or target SDK. There are plenty of examples in AppInventor that allow functionality for higher level APIs still handling non supported devices. One such example is nfc. Please read the doc I linked to.

--

File.SaveFile method currently can't create a folder


@MIT: please add the possibility to create a folder in case it does not exist
see attached example project

Tip: Working with the File component .. a new way


Carlium von duik Essoterik

Edit: this was originally posted here:  file component needs ability to create new directory.    It is a very good tip and belongs in the Tips catagory.  Thank you Carlium for sharing with the AI2 community.

I know that is not cool resurrect old post but I consider that my point maybe is ok in this thread.  (Not a problem Carlium)
Using the file component save file with a structure or path like: /xxxx/xxx.txt does not work for me. I do not know why. But I find a way to create any folder in the SDCARD.
I attached the image here.
With this method I can put files, like csv, txt or jpg in folders, create many folders and put images in the folders (this last using a hide canvas and put a standard height and width, I am looking how to improve that)

Two very important thinks to consider:

1. To share files it is necessary put /sdcard/ in the path for example:  If you create a file like: /Folder/filename.csv you must share it with the follow path: /sdcard/Folder/filename.csv

2. To delete files from SDCARD you must ignore the /sdcard/ on the path and you can use the File.Delete block with the path: /Folder/filename.csv

Due it is imposible get the names of files in a folder, I use a tinyDB and save each image and use it for delete each image one by one. Still I cannot find a method to delete folder :(

See you and hope that this information works for all people that want to do that without third party apps.

--
Thanks Steve for move the post. 

I detect a issue :S. In the emulator, USB and Wifi debugging, works perfect!. But when the apk is compiled appears a error:

width and height must be > 0

The funny thing is that still with error the folder is created. I am tried to figure out what is going on with that, the canvas is the problem.

I hope that in the next version of AI2 management of files will be priority, that is very important and sadly I cannot contribute with them due my lack of knowledge.

---UPDATE---

Very difficult fix something when only the error comes in the apk :S
The method WORKS but only if the canvas is showed. You can put a very small canvas in the screen and everything is OK. never hide or something with the canvas before try to create the folder it is a complete nightmare ;)

--
It is possible to delete a folder simply using "/folder" with delete command but the folder has to be empty. 
Deleting the files is another issue, one at a time. Still trying to figure that one out.

--

file component needs ability to create new directory


The file component is very useful.  The only problem is it can not save to custom directories, or create new directories.
If to apps created with ai are creating files with the same filename the file will be overwritten by the app most recently accessing it.
File directories should at least be separated by package name if the ability to create directories can not implemented.

--
App Inventor is an Open Source project.  Feel free to dabble wit the source code yourself!

The source code is located here:  http://appinventor.mit.edu/appinventor-sources/

--
the file component actually can create a directory, see below

File.SaveFile "/Taifun/dummy.txt"
                      "Woo Hoo"

File.Delete "/Taifun/dummy.txt"

this creates a directory Taifun in the root directory of your device
after deleting the dummy file, the directory should be empty

EDIT: sorry, this statement was wrong, see also here File.SaveFile method currently can't create a folder

--
Can I use wildcards to delete as well.  This is just a work around to the real problem though.  It is saving resource files in a common folder to all app inventor apps

--
no, you can't use wildcards
but if you like to explain your real problem, probably we can help...

--
I know that is not cool resurrect old post but I consider that my point maybe is ok in this thread.
Using the filecomponent save file with a structure or path like: /xxxx/xxx.txt does not work for me. I do not why. But I find a way to create any folder in the SDCARD.
I attack the image here.
With this method I can put files, like csv, txt or jpg in folders, create many folders and put images in the folders (this last using a hide canvas and put a standard height and width, I am looking how to improve that)

Two very important thinks to consider:
1. To share files it is necessary put /sdcard/ in the path for example:  
If you create a file like: /Folder/filename.csv you must share it with the follo path: /sdcard/Folder/filename.csv
2. To delete files from SDCARD you must ignore the /sdcard/ on the path and you can use the File.Delete block with the path: /Folder/filename.csv

Due it is imposible get the names of files in a folder, I use a tinyDB and save each image and use it for delete each image one by one. Still I cannot find a method to delete folder :(

See you and hope that this information works for all people that want to do that without third party apps.

--
@ Carlium     Thank you very much for your tip about a different way to use the File component.     I re-posted your small tutorial here to make it available to more users and easier to search  Tip: Working with the File component .. a new way

(It is OK to comment on 'old' posts if they are still open.   It is often better to start a new post).

Thank you very much for sharing with the AI2 Community.

--
thank you Carlium, this is the workaround we have to use currently
my statement was wrong, see also here File.SaveFile method currently can't create a folder

--

you can take a photo from app inventor how to return and have the name of the ph


you can take a photo from app inventor how to return and have the name of the photo to open it later if necessary? I know how to start the camera but then you have to take the picture manually while I would like to know if you can shoot without opening the camera. Thank you.

--
This inability to capture the name of a photo  is a SERIOUS limitation in AI2.     There is no Camera.SaveImageAs.    Your photo, is saved using an arbitrary number.jpg image in the Downloads folder.

With a Canvas, you can .   call Canvas.SaveAs                      fileName              
and assign a specific name.   You can not do that with Camera.


To complicate matters, AI2 has no way to view the contents of a folder.   The File component is a nice tool, but it does not provide anyway to list the contents of a folder to  show 
what files exist.  Therefore you can not specifically use this control to  delete a file unless the name of the file is saved somewhere within your app (or you remember the name).

So, you cannot use the File component to manipulate the photos you take with Camera, that is you can not retrieve them or delete them without using a file manipulation app or using the app on your device to view photos and view/delete from the images posted in that app.
.
With Canvas, you can find out the name of the file that is being saved if you grab it from a web page (Web.GotFile    and filename  will do that) but there appears to be no 
way with stuff stored on your Android device using native AI2.     

It might be possible to do find all the files in a folder using javascript.

Perhaps somone is aware of something I missed?    Please post here. :)

Also, be aware, there are several bugs in the AI2 camera component.  Please read about that here:   https://groups.google.com/forum/#!searchin/app-inventor-open-source-dev/camera/app-inventor-open-source-dev/jDu24R3584M/qwGobn6umNgJ

--
 while I would like to know if you can shoot without opening the camera.

--
Here are some hints as to creating your own javascript  that may allow you to take photos with AI2:





and LOTs of others.  Sorry, these are not Blocks.... but with your imagination and some effort, they could be.

--
it would be nice, but 
1. you will not be able to access the camera from within the webviewer and some HTML/JavaScript
2. you also will not be able to access the file system
the webviewer is no full browser and only a few HTML5 concepts will work



--
how to return and have the name of the photo to open it later if necessary? 
you get the path of the taken photo in the Camera1.AfterPicture event, just store that in TinyDB to be able to view the photo later

--
but I do not want to have to press another button to take the picture I want to take the picture by clicking on the button of my app in app inventor make myself clear?

--
Yes, I understand your question, some others here do not. Both you and I expect others to read our posts carefully and are grateful when one answers the parts of queries they are capable of answering.   It is a courtesy but not so when other parts of the comments are ignored.

In my opinion, the AI2 Camera tool is a basket case.  

The only way to  " press another button to take the picture I want to take the picture by clicking on the button of my app in app inventor" at present would be to use a java script, it that is even possible.
Taifun's solutions do NOT answer your questions about these tools or mine.   Using the TinyDB as a way to store the images for retrieval i awkward and provides little flexibility   You can use the method he proposes or use a different compiler (as I do when AI2  does not yet have a required feature).

At the moment, without a lot of coding by you or the MIT development team, what you want AI2 to do is not possible with the existing controls.  AI2 is NOT a professional compiler.  It was never intended to be one.  It has a very small development team and it provides an excellent training tool for coding and helping people use their imagination to develop ideas.  It gets 5 stars for that.  For other things,
it can do a reasonable job of allowing one to develop an app whether otherwise it would be impossible because of lack of programming skills or simple tools to do so.

If you have to code an app to do what you want, you must  either learn to program in Java using Eclipse or Android Studio.  Both are free of charge compilers. Alternatively there are other compiling tools that do not use Java..a difficult language to code in.  A very inexpensive compiler that most AI2 users can easily 'graduate' to is one called Basic4Android.   B4A uses a language very similar to the Visual Basic language used in Windows but it is used to create Android apps.   You can do exactly what you want to do in Basic4Android.  I have seen a beautiful app coded by a friend that does just that, it takes a picture by just pressing  a button in the app.   No intermediate steps.

You can help to provide the capabilities you want to AI2.  AI2 is open source.  That means you can provide and make tools for Ai2  or improve tools if you are an experienced coder.  Visit here:    http://appinventor.mit.edu/appinventor-sources/      to find out more    and r visit the forum devoted to improving AI2 and its tool box here:   https://groups.google.com/forum/#!forum/app-inventor-open-source-dev

--
but I do not want to have to press another button to take the picture I want to take the picture by clicking on the button of my app in app inventor make myself clear?
With the App Inventor built-in camera component it is currently not possible to take pictures programmatically without user intervention, see also issue 323.

I now created the Java app Take Picture as workaround for issue 323. You can start it from within App Inventor with the Activity Starter to take a picture (without shutter sound) programmatically. The path to the image will be provided in the ActivityStarter.AfterActivity event back to App Inventor. 

--
Could you write up exactly how the camera component should behave and I can try to find someone to work on it.  Thanks.

You might also have a look at the Camera.java in the sources.  You'll see there's not much there.

--
I will do that.    I will also comment on issues related to not being able to capture the contents of folders with File etc.   You can not delete unless you know the names of the files nor can you load images saved by Canvas and/or Camera ... without resorting to TinyDB, lists and other convoluted procedures.   Nice tools, but not fully fleshed out.

--