2016년 12월 4일 일요일

Percent of parent layout


When setting the width of a component, e.g. the width of a button or a layout nested within another layout, if I chose to go with percentage, ai2 calculates the width according to the total width of the screen and not the parent layout.
Can this be fixed?

-- 

“Percentage” here means percentage of the screen width or height, not percentage of a containing component.   For a button inside a horizontal arrangement, a width of 50 percent means half the screen width, not half the width of the arrangement.

-- 

Using a button to set a .wav file as a ringtone or notification


I'm making a sound board and have the sounds and have created the first screen that displays the sounds for that title.

Now, I have used player to allow the user to play the sound, but want to have a 'Set' button, where they can then set that sound as a ringtone/text/notification alert.

Having searched the forums, the last posts are from the start of 2014 on this, where it wasn't available.
-----------

Has there been any updates or improvements? If so, how do I do it?

If not,

Does anyone have any work around in order to achieve this? Can I open the .apk in notepad and add the lines of code required? If so, what are they?

--
you could write your own extension and create a block yourself...
for example you could use this snippet http://stackoverflow.com/q/29256684

more information about how to create an extension see the App Inventor Extensions document
however that will be more advanced and will require some Java skills...

--
meanwhile I added some methods to get/set/play a ringtone, see my settings extension here https://puravidaapps.com/settings.php#ringtone
com.puravidaapps.TaifunSettings.aix
settings.aia
ringtone.aia

-- 
Wow Taifun, this is great.

So you've already created the extension that will allow me to add a behavior to a button which will set it as a ringtone/notification/alarm? Great job!

I can't download it from your site, so I assume I have to pay $10 for it? If this extension will do what I need it to, then I'd gladly pay that, actually I'll pay $20 to further support your work. Btw, I don't have paypal, but do have a debit/credit card.

Let me know,

-- 
if you like to be the sponsor of that method, then please contract me by email, see my contact information here https://puravidaapps.com/contact.php. thank you


-- 

screen size


i want to make a app wich should run on a phone and on tablets.


I have a canvas with shows the World. In this canvas are many image sprites witch show the player color who leads in this land.

On the first step i size the canvas with pixels. It works fine on phone. But on Tablet its to small.
On the next step i change the canvas with percent. Now the canvas on phone and tablet is ok, but now the image sprite are not on the right position.

How can i fixed this problem?

Thanks for help
Pic1.png 표시 중

-- 
Store your pre-cooked sprite locations as fractions of canvas height and width,
and multiply by actual canvas height and width when it's time to position the
sprites on the canvas.

-- 
Hi Abraham,
thats perfect.
Its a good thing to zoom the canvas and sprites.

Is it possible to ask/read the phone or tablet what the size is, so i can zoom automatic?

-- 

Is it possible to ask/read the phone or tablet what the size is, so i can zoom automatic?
If you left your canvas visible when you packaged the app, the height and width attributes should be available in the Screen.Initialize event, or soon after.

-- 
thanks a lot

-- 

After building and installing the App, the icon doesn't appear in the phone


The problem is as follows:

After building the app in the MIT App Inventor window, saving the file to my computer, moving it to my phone (BQ Aquaris 3.5 Android 4.2.2), installing the App, when the installation is finished it doesn't let me open it and I cannot find the icon in the apps menus. I can see the app was installed in the app definitions. Please, take a look at the images attached.

Am I doing something wrong?

1.png 표시 중
2.png 표시 중
3.png 표시 중

-- 
- Does your app work allright using the AI Companion on your phone?
- Did you give permission on your phone to install 3rd party apps?
- If you did not specify an icon in Screen1, you should see the android icon instead, otherwise something may be wrong with your icon (too large for example)
- Are you sure that there are no red triangles indicating errors in your app?
- Is your app within the 5MB limit?

-- 
Thank you so much for your reply. The answers are:
1. The app works alright with the AI Companion;
2. Yes, I did, and it let it install the file;
3. I tried with no icon, and the same problem occurs. The app is installed, it appears in the definitions as installed, but i cann't find the item neither I can open the app after it was installed.
4. There are no red triangles neither yellow triangles.
5. The apk file has 1.45 MB in size.

I tried a test app with just a button and it let me install and the icon is visible in the menu. So, there must be something in the app that causes the problem. Any idea?  O:)

-- 
I have no clue ;-(
Maybe you could post an .aia here, in order to find out whether it is your PC setup, your phone or a more general problem.

-- 
Here it is.

Thank you very much for your support.


-- 
in Screen1 you have to set the icon, see scxreenshot


works fine on my Nexus 5X

-- 
Thank you for your help! 

-- 

I want to use Google Drive to download songs for an app I want to create.


I want to upload my songs into Google Drive and then on the first run of the app download them. This will allow me to overcome the AI2 app limit of 5MB.

HOWEVER, my concern is that by uploading them to Google Drive the songs will be public for everyone. So anyone can easily use the link or search Google and get access to them. Is this true?

-- 
no, only someone who knows the link to your file is able to download it
btw. this is an App Inventor forum and not a Google Drive forum...

-- 
I know this is an AI2 forum and not Google Drive forum but it is related to AI2.

So if I create an app that links to my Google Drive to download the songs, then it is not possible for anyone to access my Drive unless I specifically tell thm the link?

Also if I am downloading, does AI2 have any limits on the downloading process, such as maximum file size that can be dowloaded or the time it takes etc?

-- 
you got it

there is no App Inventor limit ... 
the limit will be the available storage space on the device...

-- 
Ok. Thanks.


--

File Extension - Copy problem


Im using Taifuns File Extension to copy files from one directory to another and Im running into a wall.

Ive tested it out and I am able to copy to the folders just fine, but now that im trying to add it to the working app I get "cant copy directory" error messages.

I have a contact app that holds info and 2 photos. Im working on an export and import feature in order to share contacts with others with the app.

I can export just fine.  Everything goes to a csv and reimports just fine.  But the pictures are giving me a headache.

The Pictures are saved as file paths in the csv.  The file path directs it to the /storage/emulated/0/Pictures/_app_inventor_image_picker/ folder.

The app uses an image picker for choosing the photo and saves a copy in the above folder with a new name.

My export uses a share (3 actually) one shares the csv. the other 2 shares the images from the above folder holding on to their new name.  The orignal picture is not in service and is not exported.

When the user recieves the emails containing the files they simply save them to the download folder and the app imports them from that folder is this fashion:

The CSV has a name, that name is entered in the import textbox and the csv is imported into the app and populates the boxes.  Within that csv is the path to the photos.
I have 2 labels set up to display the path and file name of each photo.  The Import looks at those labels and continues to copy the files from downloads to /storage/emulated/0/Pictures/_app_inventor_image_picker/.


Except, I get a Sorry,cant copy a directory.

If I hard code the file and path like the copy block that is not attached in the image above, it copys just fine.

when I try to join text in order to keep the paths the same, but make the file name change based on the info in the csv, I get the error.

I have used the File Exists block and it shows true.

Ive tried using replace block, as shown, to get rid of the file path and only display the file. So I can use that to copy, doesnt work.

Ive tried using split, and Segment Text.  That seemed to work,  But the file path is always 56 characters. fine.  The file name, is 19-20 characters. depending on the file.  So It throws and error saying the files too long.
Is there a way to use the segment text block and say :start-56,  length - open or count how many spaces in that file name?

Ive also cleared out the test phone and dumped the cache several times in order to see it clean.  

Any ideas?

-- 
use Do it to debug your blocks, see also tip 4 here

Top 5 Tips: How to learn App Inventor


 I get a Sorry,cant copy a directory.

you only can copy files and not directories


-- 
use Do it to debug your blocks, see also tip 4 here
Top 5 Tips: How to learn App Inventor

 I get a Sorry, cant copy a directory.

you only can copy files and not directories


Refer to my previous: Im using Taifuns File Extension to copy files from one directory to another and Im running into a wall.

Im only trying to copy a csv, a jpeg, and a jpeg from the Downloads folder to the /Pictures/_app_inventor_image_picker/.

Ive tried the do it and something interesting has happened.

I attached the blocks to the import button.  When the button is pushed it checks to see if the txtbox has a name to import then sees if the file is in the download
folder, if it is it Reads from that file into the app and saves. - this works.
When I add the copy from this same directory it gives the error of Sorry cant copy a directory.

Heres the weird part.   If I click do it on the copy block- it works.

If i move the copy block to the Got Text block - It works (except it doesnt display the photo until you go to the list picker and pick that name - refreshing the contact.)

It only throws the error if the copy is in the same blocks as the read from the csv (which I need to do first in order to get the filename of the images)

When you made the extension is there a limitation that says can only do one thing?  Read or copy? Not both?

-- 

If i move the copy block to the Got Text block - It works 

it seems to be, you have a timing issue? unfrotunately I can't find that event in your screenshot?
also you renamed the components, which makes it hard to understand your blocks...
you are using the web component, correct? the web component works asynchronously, which means you only can do something with the file after having received it and not earlier
for example first download the file, then receive it and then copy it to somewhere

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

-- 
Your exactly right,

Ive been playing with it and it has to load the csv into the app first, then it can copy the files.

Ive been trying to work on the timing in order for the picture to populate when the fields do.  A timer works, but doesnt populate the images until after I go to the list picker and choose the new entry.

Im trying to put a loop in the import of a second or so to see if that works.

Is there a way to 'refresh' a listpicker?  Can I tell it to open the listpicker and choose the same file that was imported?  (the name of the import is not always the name of the listpicker.)

thereby 'refreshing' that record and displaying the images?

-- 
don't use a timer, see this example how to download some files asynchronously https://puravidaapps.com/filebyfile.php


Is there a way to 'refresh' a listpicker?  Can I tell it to open the listpicker and choose the same file that was imported?

???
sorry, I don't understand, you might want to elaborate
you always can assign a new list to the listpicker elements property and to open a listpicker use the open method
Taifun

-- 
Ok, Got it working.

Your right, it was a timing issue. I put the copy blocks on the import got text block and the only thing I could do was to call OPEN Listpicker after it imported

This added it to the list where I could choose it again and see all the information.

I was hoping I could simulate a screen refresh (not really but the end result would be the same).

After the import occurred, I tried programmatically open the listpicker and choose the recently imported contact.
Giving the effect that the import occurred and your seeing what you just imported. (refresh)

Still working on the refresh... Thanks for the Help!

-- 


how to transfer an action from one screen to another screen


I have already designed my app now, but i try to figure out a problem.

i build a turn on and turn off button on the first screen. And i want to show the on/off status on the second screen. How should i do?

I have already uploaded two screenshot. As the figure shows, the first one is the screen 1 which has On/Off button. When i click the ON or OFF then i want to show the LED is ON or OFF on the second screen and list below the check information box.

1.PNG 표시 중

2.PNG 표시 중

-- 
How to pass values from one screen to another screen

Use different screens wisely
Before starting to create another screen, first you should think about is it really necessary? See also Building apps with many screens and SteveJG's post about advantages/disadvantagesbecause in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed... See also Martyn_HK's example about how to use Tabs in App Inventor and another example from Cyd.
      
The recommended method of switching screens in AppInventor

-- 
First of all, thanks for your replying.

However, my idea is when i click ON or OFF button, the second screen will show "THE LED IS ON/OFF." I have already tried to use those idea, but it doesn't work.

-- 
There's no real time communication between screens. What you have to do is what Taifun showed you in his link.
Is like this. You have a house than can only have one person at a time inside. If you want the next person coming after you to do something, you need to leave him a note. He will never know what to do in the house until he gets inside and reads your note.

Screens works the same. You need to leave a "note" in the current screen and when the next screen opens, you read that "note" and set the ON/OFF switch to whatever you wrote in the note.

Please read the link Taifun gave you to learn how to leave these "notes" for the other screens.

-- 


Moving label follow ball


Hi! I'm trying to complete Project Lead The Way's 1.2.5, part b under "Tasks Making a Larger Contribution". The problem is "Add a piece of text directly over the ball that counts milliseconds to add a feeling of rush to the game. This piece of text should stay in the same position relative to the ball regardless of where the ball moves. Now, I have figured out how to count the milliseconds using a label, but it needs to follow above a ball, which is rotating across the screen in a counter clockwise direction. If anyone could reply and show me how to make my label move with my ball, that would be great.

-- 
you might find some ideas after doing a search here in the forum or in Scott's Developers library here https://groups.google.com/forum/#!searchin/app-inventor-developers-library/sprite$20text%7Csort:relevance


-- 
☞ How to convert zip file into aia file

This technique of copying screens in an AI2 project uses Windows Explorer to add new screens to an AI2 project. 


When copying screens manually, be careful not to use keywords such as 'Button' for your new screen names as 'button' is one of the words used in component definitions in the screen files. Manually copying a screen named 'Button' will cause any button definitions to be corrupted by replacing 'button' with the new screen name and the new screen will not work. I add an SCR suffix to my screen names to insure that this does not happen. Alternatively you could make sure that you avoid those keywords.



Also, when copying screens from one project to another, be sure to also copy any assets needed by those screens from the source project to the destination project.

Screen CanvasSCR will be copied and named ClockSCR. I captured the screens for each step of the process below: 

Export your project to a folder on your computer.
Then place a copy of it with the original name in another folder for adding the new screen to.

Replace the aia extension on the copy's project name with a zip extension:

Open the project with Windows Explorer:
Navigate to the folder containing the screen files:
Drag the files with the screen name to be copied out of the archive:
-
Edit each file:
Replace all instances of the old screen name with the new screen name:
...then save each file.
Rename the Screen files to the new screen name:
Drag a copy of the the renamed screens to the archive:
Change the project extension back to aia:
When you import the project into AI2 it will contain the new screen. If you have an <old screen name>.Initialize block in the original screen it will now be named <new screen name>.Initialize in the copied screen.
-- 

Blinking button?


Hi, maybe somebody can help my with blinking button.In general i want to make button blinking when player playing .Do not know how to do that.Lets say if i do with two button images ledlighton.jpg and ledlightof.jpg to channging in clock seconds speed.I need not color changing yelow to black but picture changing or dimming.Or maybe possible somehow make response button on click dimming (already in MIT appinventor).Any ideas or directions what i can try?Or maybe that not possible on MIT app inventor?Thank you in advance

-- 
use a clock component and an if block like this

if Button1.Image =  ledlighton.jpg
then 
  Button1.Image =  ledlightoff.jpg
  Button2.Image =  ledlighton.jpg
else
  Button1.Image =  ledlighton.jpg
  Button1.Image =  ledlightoff.jpg

-- 
O  thank you! Learning not easy thing :)

-- 

Viewing Large Image Files


My app needs to show large (1000 pixels x 1500 pixels) jpg files on a smartphone.  The user should be able to scroll the image up, down, left and right and the user should be able to shrink and expand the file.  Just like you would do with a photo in a photo gallery.  I've tried a few different methods and the webviewer interface component seems to work the best.  But its not very smooth and seems to have trouble when the phone rotates, profile to landscape and back.  I've tried different sizes of different interface components and layout components. I've gotten different pieces to work somewhat but there always seems to be something it not doing right.  My latest attempt was with intents using "VIEW".  and pointing to a file on my phone but I get a "601" error.  Not found or something.  I was hoping I could pass the file off and let the intent do the work of scrolling and sizing.  Is that possible?  I've scanned most of the recourse on line, but have not found anything that discusses the best way to do this.  Does anybody know of such a article or what the best way to program AI to display large files?

-- 
How about forcing app to one particular orientation & using webviewer?

-- 
Fixing the screen orientation solves the problems with moving from portrait to landscape and back, but that was a feature I wanted to provide.  When I look at picture in "gallery" the photo viewing app that came with my phone, I see the whole picture at first and then I can zoom in and move the photo around to get a closer look at something in the photo.  All this moving/zooming is very smooth and easy.  When I use the webviewer component, the first image I see is a portion of the page (I've tried different heights and width combos) and the zooming and moving is very clunky (very technical term), not smooth like gallery.  Maybe it's just the way AI works, maybe its too much overhead.  I'm just wondering what others have tried and and how well its worked.  Maybe I'm being too picky. 

-- 
You could have a canvas that is larger than the screen and try scrolling using the canvas events.

-- 
Thanks for the suggestion.  If I understand you correctly, you are suggesting I use the canvas component with the events as input and move the image file around programmatically. I tried using a canvas early on and using sprites as navigational buttons. But I found that  controlling the graphics was becoming a nightmare, so I abandoned it.  Upon your suggestion I took another look at the canvas component and I found that the canvas input events, like swiping etc where covered, however moving the image around and sizing it dynamically looked very hard, if not impossible via AI2.  A lot of trial and error, especially using different devices.  

Perhaps this post really should have been a discussion, not a question.  After doing some more research it looks like I have two options.  One, go with the webview component and live with the clunky movement and sizing. Or, two, trying to find a "VIEW" intent and activity starter, which I know very little about and see if that can handle my dilemma. Can anyone point me in that direction?  I've read the AI documentation and it's a start. Well, maybe I'll learn something. 

--
Just to add to the discussion, Taifun has two image extensions that may be helpful to you:
• crop.aia

-- 
Looks like I found an intent, or rather found out how to use them, that does the job for me.  Seems I was leaving out the "Datatype" parameter.  Thanks for the paravidaapps web sites.  Although it wasn't exactly what I was looking for , it got me started looking in the right direction.  What finally answered my original question was the "AppInvActivityStarter" app at Google play.  Its a handy tool to test common intents.  After some trial and error, I discovered what was needed.  

One, well two, minor concerns still exist.   The intent I'm using does everything I want it to do and more.  Namely if you swipe the screen, the user will get the next image file in the folder, like in gallery.  I don't want that to happen.  I'm wondering if there is another parm I can use to prohibit that from happening.  I'm going to play around in the app I found, but it looks like my options are limited.  The other concern is my inabitlty to resolve tech type questions using the google android developer site.  I couldn't really find  the documentation, about how the parms were used in intents, like I could using trial and error and the app I used.  Maybe, I'm just not tuned in yet.  Anyway,  I can start developing my app.  If anyone has an answer about limiting the swiping action of the VIEW intent., let me know, Thanks  

-- 

How to open screen only once in multy screen


I have 5 screens on mode random open screen, i want open screen only once, how?

contoh.png 표시 중

-- 
Different situation .. look my project 

contoh.png 표시 중

-- 
you previous question was how to pick a screen only once
so what is your current question?

-- 

, i want open screen only once


Only once ?

That's ambiguous.

Once a day?

Once an hour?

Once in the lifetime of that app on that phone?

Once until a Reset button in the app is pressed?

Choose one.
-- 
Once until a Reset button in the app is pressedYes, How?

-- 
Pertanyaan = Question
Jawaban = Answer

i use pic random Question but Answer not synchronize with Question, how to synchronize both of them? Thanks

contoh.png 표시 중

-- 
follow the link from my last answer and use the random integer block instead of the pick a random item block
you might want to adjust that example to your needs

-- 
Like that, i've tried that its not working

contoh.png 표시 중

-- 
you might want to display the index in the label after it has been chosen

 Unbenannt.jpg

also it probably would help to tell us, what exactly does not work...

-- 
That
contoh.png 표시 중
Screenshot_1.png 표시 중


Screenshot_1.png 표시 중
-- 
unfortunately I don't understand, what you are trying to tell us, probably someone else does? 
you might want to elaborate what you like to get and what you get instead

see also tip 4 here
--