2017년 8월 1일 화요일

Can AI2 capture an image of the device screen? How?


I need to capture an image of my tablet display running an AI2 project using WIFI.  Is there a way to do this using AI2 itself?  If not, what would be a good Android app to do this (non-rooted)?    I can not simply do this in the emulator because I am using controls that do not display or report in the emulator.  If I can capture, I can easily transfer to my PC, the issue is how can I get a screen image png or jpeg?

--
Use monitor.bat in tools folder of android sdk

--
Fantastic.  Thank you Hossein.  It works great ... after downloading drivers to use the USB with my tablet, setting the Developer Mode on th tablet,  "learning" to use AI2 with USB  and bringing up the Android Debug Monitor  the suggestion worked very well    I have used ADB with Android Studio and Eclipse but never with AI2 and did not realize I could capture a screen  Wonderful.

--
Aaron just showed me another way. .   I can take a picture (screenshot) ... using the shut down and volume buttons on the Galaxy Tab II, but not as described in a posted article and awkwardly, Using thevolume and shutdown  buttons does not always work.  Some things just do not work as planned.    Thanks again Aaron, Just wanted you to know.

--
I could not find the key combination to snap a picture on my Monster M7 tablet running Android 4.1.1.
I found that you can add an icon to the menu in the Settings:
--
Thanks for the image Scott.  I understand prior to upgrading my Galaxy Tab II to Android 4.2.2. it too could do exactly what your Monster can do.  Sadly, that feature was removed going from 4.1 to 4.2.    I suspect others will find your experience useful.

--
I just learned by trial and error, that with my Tablet, I can press the on/off simultaneously with the volume control to take a screenshot if I press the volume control in the MIDDLE....of the increase volume/decrease volume buttons.  The tablet takes a screenshot every time!   However, there is an issue; the screen shot only captures the entire screen if the app is in landscape mode.

--

Issue with App Inventor itself


I decided to create a new screen in my app.  Before I did anything with the screen, I added a new page but then realized I gave it the wrong name.  I then attempted to remove it but got an error.  The screen is still listed in my screens list and it will not allow me to access it.  I would like to remove it completely.

The system told me that an internal error occurred and asked if I would like to report it.  I did..

I did manage to create my new screen with the correct name without an issue, but the old and incorrect screen seems to be stuck.  Can anyone help?

--
Nevermind.  When I closed the browser and restarted my session, the unwanted screen was gone.  Everything is fine. :)

--
Was there anything extraordinary about the screen name? This sounds like it could be a potential bug and I'd like to see if we can repeat it and squash it.

--

Chat app in MIT App Inv 2


Hey there I want to create a app in AI2 I want to get and store my users on a DB online, but I don't want to store the messages on my server and I don't want to relocate our server, sadly the UK is trying to push a law where message providers must enable users to save all there messages, location, name, device details in plain readable means for them to read it if they deem it so, I don't agree with this I don't agree with me or staff members reading private messages so I don't believe anyone else should, I will be creating a report option that if anyone is spamming or abusing a user it will then report the user and unencrypted messages sent, and if I can't find means to send drive to device once logged in but if I can send device to device then only messages saved would be reported messages.

I would like ideas if its possible to do this in AI2, with anything that is around like the JavaScripting or other tools, If I can remove this stress of having to save all this data it would be great I have also priced it up for the new over heads of saving this kind of data and well I not rich.

I hope this new law will never come in to play but I have to take it in to account now looking forward on my apps.

I am able to handle users login details online and this could also hold means for addresses to send the Direct messages to, I been able to do similar things one windows and web sockets seems to be able to offer this if I want to offer a browser based system, but I would love to offer a native app well AI2 Native lol I am not that good with new symtecs and I forget code a lot.

--
probably this example can help http://puravidaapps.com/pubnub.php

--
No this is still a 3ed pasty service that would have to handle that data, and if the law ever came in to play they would have to do the same or not offer UK any services,
Also I looked at them I trying to make things for other people and I wont have ads or charging them for it, I sick of people saying or use this service here or there when clearly when you hit a mark you have to play, this word is not about money, that is another rant there but I leave it at lol



'I don't want to relocate our server' - also using a 3ed party to handle the messages would also mean relocation of the service of the message part, this tech is out there its far and to the point, people been so scared of using it these days, I remember 10 years ago p2p was everywhere from in your game systems to ever day apps to download your seedy porn lol but now its all NO we can;t do that, no you can do that stop replying on a middle service to bloody do the work, p2p means just that p2p no server in the middle, if my app went down I would hope to include another means to get the users address to share there lifes without some fool in the middle having to know what there doing.

Another reason I want this in AI is so that everyone can get in on it, everyone can try and make something, if windows 10 can now use p2p tech in there OS to share updates and spy on use I think we should be able to make a simple app that sends a message from one user to another, I can't believe people these days pay out of the noise for message relay services that never last a few moments if your lucky you get a big one a few years but the point is there not needed and I am shocked people are letting bigger companies have money out of you for something that is not needed.

Don't get me wrong I like playing with servers like Googles new message service would love to see that in AI also, but this day and age I am shocked to how pussy footed we have become :(


Don't get me wrong your idea also works for small apps that you just want to add a simple chat to, 100 devices, 1 Million messages is OK for a baisc user but I am not looking at a fast fix app that could be dead tomorrow I want to be able to make a app what will work when any of these servers have gone, p2p other this kind of idea, I am one for tech after its best used by date lol

maybe I am asking two much from a world that can program so many cool things these days.

--
Well, I just read how Gnutella works.
Since it is peer-to-peer with no intervening web server, I don't see how two devices running App Inventor would connect directly.
My experience in the past has been with an AI client communicating with a php server.
I can also see the possibility of using a service like DropBox or Google Drive to share simple text files that can store texting conversations with the AI clients polling the file(s) for changes.
You might employ encryption to insure privacy routing your conversations through a javascript encryption engine on the device.
But, again, you are relying on an intermediate computer somewhere on the internet.
Searching for peer to peer javascript I came across PeerJS.
This or some other javascript-based method might make use of App Inventor's ability to share data between itself and html documents on the device using the WebViewer component.

--
Reading about how PeerJS works -- it does use a server but...

PeerServer
To broker connections, PeerJS connects to a PeerServer. Note that no peer-to-peer data goes through the server; The server acts only as a connection broker.
PeerServer Cloud
If you don't want to run your own PeerServer, we offer a free cloud-hosted version of PeerServer.Start by getting a PeerServer Cloud API Key!
Run your own
PeerServer is open source and is written in node.js. You can easily run your own.

--

Communicating Between WebViewer and App Inventor


This is a 2-part post.

Part OneI've tried out fourteen communication apps to help people with disabilities or children with special needs communicate.  12 of them are pretty awful, but I did see something really cool.  (Sorry I don't remember the name of the app.)  A webviewer allowed the user to view Google search images.  When the user tapped image, a menu (like the menu you get when you right click) popped up.  "Select image?" I think was the only choice.  When I clicked that, it took that image from the web and brought it into the program.
Too cool.
Does anyone know how to interact with webpages like that?  I know you can press buttons with JavaScript, but how do you pull off something like that?
Maybe get the images from Google and then display them like it's on Google, with an onClick property for each?

Part Two

Speaking of onClick properties, I'm trying to create an image listview using the Web Component.  In App Inventor I set the WebViewString to a csv row of image urls, filepaths, and asset names.  The webpage has a script that displays the images.  That part works fine.

Every so many milliseconds, App Inventor sets a label to the WebViewString property (using clock timer).  When an image is clicked, the WebViewString is set to the url, filepath or asset of the image.  To each image is: onclick="window.AppInventor.setWebViewString('+ val +')"  Val is the url, filepath, or asset (the list of them is looped through).

For some reason, even though the onClick fires (I've tested this), the WebViewString is not set.

Tim Carter's been helping me edit the code (which I got from the third post from the bottom on this topic).  He suggests I "focus on the syntax in the javascript until it starts producing output".  I don't know what else to try, so I'm asking if anyone
 knows any ways to set the App Inventor Web Viewer component's WebViewString from within the HTML.  I have tried windowAppInventor.setWebViewString("text here") but in this specific circumstance it is not changing the WebViewString.  I've also tried window.AppInventor.setWebViewString().

Or is there a better way to communicate between the webviewer and App Inventor?

P.S. I've already read the documentation on this.

P.S.S. I have put my code into Khan Academy's webpage tool, which gives you errors if your code has errors, such as using a ' inside of a string that starts and ends with ' (like 'The dog's leash' would give an error).  Now I'm error free.

--

search results for No me deja descargar el archivo apk.


Hi, I have done an app, but when i try to download it generating the qr code to download it in my mobile, it doesn´t work. What's wrong? How can I ...
el intentar descargar mi archivo apk de mi pagina me genera un tipo de error que no se como solucionar necesito ayuda, el dia de ayer estaba ...

Will not let me save my apk file


The attempt to download my apk file from my page generates a type of error that I do not know how to solve I need help, yesterday was working normal and yesterday at night when I tried to download it I came out a very long sign and did not know what to do, My page I have to present it in 3 days I need help to solve that
Side Compilation! The request for http://newblocksbuildserver.appinventor.mit.edu:9990/buildserver/build-all-from-zip-async?uname=camiloyonda9%40gmail.com&callback=http%3A%2F%2Fnb151a.395824815188772934.mit-appinventor -newblocks.appspot.com% 2Fode2% 2Freceivebuild% 2Fd72yeb0xp0jjz6uhbesw514akp5jcpis7i4vgp18ydentr96nvrlfo1462m9tnekaqap48npef2ut79h80p0ppciyi4qh0gy512o8qnsaigzwfjkwefam427wpvslp2y5mrtjjruu0% 2Fbuild% 2FAndroid exceeded the 10 MiB limit.

--
Your application is too large, perhaps  has many large images.
Reduce the size of your images, try to use fewer images.
With Ultimate Portable App Inventor, you can create application more than 10 MB


--

Do not let me download the apk file.


Hi, I have done an app, but when i try to download it generating the qr code to download it in my mobile, it doesn´t work. What's wrong? How can I resolve this?

--
which error message do you get?
you might want to use the other option (save apk to my computer)

--

Fusion Table Looping problem


I'm a middle school student working on an app for a project. I need some help with my fusion table on Screen 1. It keeps looping after users create an account. Can someone help? I'm new to app inventor and have completed the Pizza Party tutorial. I got that to work, but am really stuck. 










--
after getting rows or inserting rows always the GotResult event will fire!
you could use a global variable (let's call it action) and set that variable to "GET" before getting rows and set that variable to "INSERT" before inserting rows
then in the GotResult event check that variable like this

if action = GET and username is available
then do the INSERT
else if action = INSERT
then display a message "user has been inserted successfully"

btw. you might want to reduce some redundancy...
for example why do you use 6 different global variables to store the same service account email address?

Store password hashes instead, my tools extension https://puravidaapps.com/tools.php can help you with a hash method... and during login, compare the password hash with the stored password hash in the database...

Packet installation program has been interrupted


I created my last app and I have a problem (the install program crash, telling that the packet installation program has been interrupted) trying to install the apk on my phone (Samsung S6 with android version 6.0.1), while the same app work well on the same phone when used over wifi as companion and even I could install the app without problems (like usually I do) on my tablet with older android version 4.2.
It is a simple app, so I cannot understand what went wrong.
Can you tell me what can cause an installation crash?

--
probably a memory issue?

to find out more about the installation issue, you can use Logcat

I normally use Eclipse and Logcat there, but if you have installed the App Inventor Software (see also Installing and Running the Emulator in AI2), you already have everything you need to use logcat...

How to use Logcat
1. connect your device using USB with your computer
2. in File Manager go to the App Inventor directory, which is  C:\Program Files\App Inventor or similar
3. press Shift and right mouse click the subdirectory commands-for-Appinventor to get the context menu
4. select "open command window here" and you will get a command window of that subdirectory
5. enter adb logcat and the logcat will start running
6. start your app to elicit the error
7. copy the log (see below)

To copy your log, right click, click "select all" and enter to copy the complete log into the clipboard, then open Notepad and paste it using ctrl-v.

--

is it possible to copy an image into directory?


my app can put an image into server from the directory (created by app in firstrun process) and downloading them, if there was not in that directory but they should.
Now I only want put some image after image picker been triggt into that directory. Puting that image into server will be done automaticly leater.
I can do it by puting that foto into server and downloading it and save it at this directory but im sure that there is some easy way to copy an image. I'm right?

ps. Sory for my english. If you dont understand my problem, let my konw and I will try once again with google translate, this time.
ps2. @tajfun. My app exist only thanks to you. Thank you for materials that you publish. 

--
but im sure that there is some easy way to copy an image. I'm right?
I'm not sure, if I understand everything what you were saying, but to copy a file you could use the Copy method of the file extension https://puravidaapps.com/file.php ... (EDIT: link corrected)

--
404 Not Found :/You sure, that you give my correct link? 

--
ok. i found that extension on your site. I will try use it. Thank you :)

--

Problem of data mismatch between arduino and android app


I have developed an android app which can show raw data of strain gauge and can calculate the force applied to it via Bluetooth through Arduino Uno. Usually, at the very beginning, it can work well, but a few seconds later the app cannot get along with the data transmitted from the arduino and there is mismatch of data (for example, if a sequence of numbers "8148888 8148070" is transmitted, it will get "148888", or even "148888 8148070" at one time. How to solve the problem? The best way is to provide an solution that can make the app auto-match the data. The worst way is to tell me the way to automatically ignore warning windows (the app can still work if I just ignore emerging warning notification by tapping blank areas). Thanks.

PS: the Android code:

#include <HX711.h>

#include <SoftwareSerial.h>
SoftwareSerial BT (2, 3); // RX, TX
#define DOUT  5
#define CLK  4

HX711 scale(DOUT, CLK);

void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  scale.set_scale(1);
  BT.begin (9600);
}
void loop() {

  // put your main code here, to run repeatedly:
   long rawdata = (long)scale.get_units();
   delay(20);
   BT.println(rawdata);
  Serial.println(rawdata);
}
The App inventor blocks:



--
Your data stream is sliding around, making it hard to parse on the receiving end.

Set the AI2 BlueTooth Client Delimiter attribute in the Designer to 10.
(10 is the decimal equivalent of LF)
Also, in the Blocks Editor, set the BlueToothClient.ReceiveText to ask for -1 bytes.
This will feed you exactly one println() worth of data at a time.

Display the incoming data, so you can see how to process it more.

--

Make a sprite follow a pre-determined path


I have scoured the forum and googled this but cannot seem to find an answer.

What I would like to do is to tell a sprite to follow a pre-determined path.   I though something like this might work:

Clock:
    at 1 second move sprite to X=10, Y=20
    at 2 seconds move sprite to X=15, Y=25

but the clock function doesn't seem to work that way.  

Any ideas?

(I have no screenshots to offer because I have not made this work...sorry)

--
one possibility is put all your x and y coordinates into a list of lists
then use a global variable (let's call it index), which gets incremented in the Clock.Timer event
and select the current item from the list (using the index variable) to get a sublist of the current x and y coordinates
now use the Move method to move the sprite to that coordinates

see also

--
I will give it a go. Thank you.

--

Rotating clock too slow


I cannot find an error in my code.The problem is,the semicircle is rotating too slow(consequently the clock is too slow).
My target was to make it rotating 1 degree every 17 miliseconds 360 times(6 seconds).
Is it too fast for application?



--
you will have to optimize your logic, for example you are using 7 clock components, try to use only one clock and some if statements instead
each event needs some milliseconds for the execution... there also might be some other tasks running on your device, which will need some processor time

My target was to make it rotating 1 degree every 17 miliseconds
in case that does not help, try to rotate 2 degrees every 34 milliseconds

Is it too fast for application?
this also depends on your device...

--
While using sprite image,is there a possibility,that the clock timer collide with sprite interval?
How should I set the interval to make it work right?

--
see here The model of event processing in App Inventor by Lyn

How should I set the interval to make it work right?
how did you set the timer intervals currently and what is the purpose of the different clocks?

--

HELP: My Webviewer cannot find local HTML file


Thanks in advance for helping...
I already followed this guide--
But my webviewer still shows that WEBPAGE NOT AVAILABLE screen.
When I replaced the URL to something in the internet, it shows perfectly.
But when I try a "Test.html" that I uploaded using AI2 as media file, (and I can see it stored in my phone at this path /sdcard/AppInventor/assets/test.html),
then I set the URL of my webviewer to "file:///mnt/sdcard/AppInventor/assets/test.html" , it cannot be found.
I already tried several other combinations of filepath but nothing works.

what else should I check?


--
I did some trial and error, and found out that the response is different when I run in Thunkable vs when I run in MIT AI2.
The local file path works fine with MIT AI2 but not in Thunkable... being not too technical, i don't really know why it behaves that way.

--
Have You checked this issue of Your code:
https://puravidaapps.com/snippets1.php#htmlread

There is one special thing to consider for HTML documents uploaded as assets into App Inventor: During development, you have to use the development path to the embedded HTML document.

file:///mnt/sdcard/AppInventor/assets/<NAME OF YOUR HTML FILE>.html
Before packaging the app, use the production path.
file:///android_asset/<NAME OF YOUR HTML FILE>.html
<quote>
--
Or check out Taifun's tools extension which provides a block for the assets directory, regardless of whether you are developing or running the apk

--
The local file path works fine with MIT AI2 but not in Thunkable.
this is a Thunkable issue, see also here, you might want to ask there

--
I'm having the same error, too, but it's App Inventor that it's not working in...

I created the file with SaveFile in the screen's initializer, set the home URL to the correct path, and .GoHome-ed.



--
you are storing the file in the private data directory of the app. The webviewer is not able to access that directory, you will have to store it on the internal sdcard and open it from there 
EDIT: see correction below

SaveFile(text text, text fileName)
Saves text to a file. If the filename begins with a slash (/) the file is written to the sdcard (for example, writing to /myFile.txt will write the file to /sdcard/myFile.txt). If the filename does not start with a slash, it will be written in the program's private data directory where it will not be accessible to other programs on the phone. There is a special exception for the AI Companion where these files are written to /sdcard/AppInventor/data to facilitate debugging. Note that this block will overwrite a file if it already exists. If you want to add content to a file use the append block.



--
Hmm.  I did start it with a /.


--
sorry, I was confused... you store the file correctly on the internal sdcard
but later you like to read it from the assets, which does not make sense...
use the full path to the file, which is file:///mnt/sdcard/ImagesListViewVertical.html

--
Oh my gosh!  I forgot it wasn't an asset!  (I've been working on asset HTML documents way too long.)  

--

Alternative solution for Serial port profile of Bluetooth or BLE


I am trying to establish a stable connection between cellphone and dev kit, then send data via link as serial port. (The dev Kit supported BLE and Wifi right now.) My goal is to have some connection/communication between cellphone and dev kit similar as Serial port profile of BT or BLE. However, I ran into some issue due to unstable BLE connection which is tore down after 32sec always regarding if I keep sending data every 500ms. I will keep working on it, but meanwhile, I am just looking for another way to do similar functions? do you have any suggestion?

first thing comes to my mind which is to setup wifi connection and establish TCP connection between cellphone and Dev kit, so cellphone can send data to dev kit etc, but I did not see such blocks supported in AI2, and not sure how to do it? in other words, is there alternative to implement similar function?

--

--

WebViewer shows not only the Table of a Fusion Table


I want the webviewer to just show the table of a Fusion Table, but it shows all the details, and it'is even fully editable (see screenshot). Where did I go wrong? How can I solve this?

--
do the Pizza Party tutorial and take a look especially at the URL the webviewer is using...

--
found it... copied the wrong link!
thank you!

-- 

How to fire a Random Clock?


Can anyone lead me in the right direction for firing a random clock?   Basically when a button is pushed, I want a random clock to be fired and the clock set off a chain of events.  

--
Further details are needed.

If it's a small number of predefined actions that you want to happen, and your code will be substantially different between any one action and the next (aside from choice of sound or picture, which you could otherwise just randomly choose from a list), you could pull out some small number of inactive clocks in the Designer, and at Screen1.Initialize time collect their components into a global list, for use by your random event selector and the Any Clock blocks.  

You would need to code Clock.Timer events for the different Clocks.

If it's just random sounds, times, but the same processing, you can work with just one Clock and pull your sounds, text, pictures from lists randomly.

If you need the Clock to fire at a random time within the next hour, you can calculate a random number between 0 and 
(60 minutes/hour * 60 seconds/minute * 1000 milliseconds/seconds) milliseconds and set your clock to fire at that interval, not repeating.

Have I missed any thing?

--
Oh, and I forgot.
AI2 can't run in the background, so don't pick a long interval
or your phone might go to sleep.

--

autocomplete


i'm trying to create an autocomplete procedure.
i write something in a textbox, if the input is present in a list, the procedure should complete the input in the list and write it on the textbox.
obviously it do not work
the clock interval is 100 millisec
--
You are passing a textbox component to a procedure,
but treating it in the procedure like it was that textbox's .Text field.

Pull in an ANYTextbox.Text block into the procedure to get the text value.

--
Also see

--
great stuff. thanks, i think it's just what i need.
and i read too that there will be a new feature related to lists!! just excellent
--
i'm trying the way of the first post, but not setting the text of the textbox, instead setting a result list in a list view
but i'm not good with any component, if you can look at this..
--
You don't need an Any Textbox block because you only are working on one text fragment at a time in this procedure.

Based on what you have coded, I guess you want the procedure to update ResultsList with a list of words that hold this fragment, chosen from the input parameter List.

For starters, fix the names, so you have a basis to avoid mistakes on what does what.

The procedure should be renamed to collectWordChoices
You forgot to empty out ResultList before you started to add words to it.
Rename the List parameter to AllWords, since I image it is where you keep all the words to try to match.
Replace that first step in the procedure with setting global UserText to the current contents of the text box, either by passing it directly or passing in the entire textbox component.
That first green  step was assigning in the wrong direction.

--
i made it easier to understand what is wrong.
and nothing, it doesn't work neither in this simpy way!

abraham the savior i wait for you
--
You are doing in a button click event what should be done in a repeating Clock Timer event while the user types into that Text Box.

You also need to add a ListView.AfterChoosing event to deal with taking the user's choice of Organization and plugging it back into the TextBox.

--
Also, go back and read the doc I mentioned on how to do autocomplete...  How to do Autofill

--