User Tools

Site Tools


getting_started:faq

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
getting_started:faq [2015/04/10 15:51]
65.124.239.82 Added another question that someone might have an answer to.
getting_started:faq [2017/10/21 14:57] (current)
Line 1: Line 1:
 ====== Frequently Asked Questions ====== ====== Frequently Asked Questions ======
-This faq is expected to grow significantly over time. Please feel free to add to it or correct any mistakes.+This faq is expected to grow significantly over time. Please feel free to add ideas to it or correct any mistakes. 
 +===== What measurements does DroidScript use? ===== 
 +In order to maintain the scale of graphical objects in devices with different screen resolutions and orientations, all positioning and sizing values are given as a decimal **fraction** of the screen width or height.  
 + 
 +For example creating a button with a width of 0.5 would make the button half the screen width and using a height of 0.1 would make the button one tenth of screen height. 
 + 
 +You can however leave out the width and height parameters on many controls if you want the control to size according to its contents. 
 +===== Do I have to use layouts? ===== 
 +**I am a web developer and just want to use my skills to build apps.**\\ 
 +No you don't have to use layouts any more. 
 + 
 +When you create a new project, you have the option to create either a JavaScript app or an HTML app. 
 + 
 +The HTML type is much more like designing a web page. 
 ===== How do I set an icon for my app? ===== ===== How do I set an icon for my app? =====
 To see a personalized icon for your script in the program overview of DroidScript, place a .png file as asset in the folder Img with exactly the same name as your script. To see a personalized icon for your script in the program overview of DroidScript, place a .png file as asset in the folder Img with exactly the same name as your script.
Line 7: Line 21:
  
 The easiest way to do this uses the **[[getting_started:wifi_ide#using_uploaded_images|Wifi Ide]]** but it can also be done directly on your phone/tablet using your file-manager. The easiest way to do this uses the **[[getting_started:wifi_ide#using_uploaded_images|Wifi Ide]]** but it can also be done directly on your phone/tablet using your file-manager.
 +
 +There are more notes there about the App icon requirements as well. See... [[getting_started:wifi_ide#App Icon|App Icon]]
 ===== What is an SPK and how do I use it? ===== ===== What is an SPK and how do I use it? =====
 An SPK is a DroidScript package.  An SPK file is generated automatically by the DroidScript app when you share your app.  To create an SPK file, long press on your script from the main DroidScript screen and select "Share via Email" You can either proceed with sending the SPK to yourself or someone else via email, or cancel and browse the Android filesystem to get at your SPK file.  The SPK will be located in the .DroidScript/Temp directory. An SPK is a DroidScript package.  An SPK file is generated automatically by the DroidScript app when you share your app.  To create an SPK file, long press on your script from the main DroidScript screen and select "Share via Email" You can either proceed with sending the SPK to yourself or someone else via email, or cancel and browse the Android filesystem to get at your SPK file.  The SPK will be located in the .DroidScript/Temp directory.
  
-To use an SPK, you need to import it into DroidScript.  Once you've got the SPK, Long press on it. Then share it to DroidScriptWait for a Second or two, A dialog Box will appear whether you trust the source or not. Press yes. SPK will be created and you can see app.+To use an SPK, you need to import it into DroidScript.  Once you've got the SPK,Press on it. DroidScript will open, Wait for a Second or two, A dialog Box will appear to ask whether you trust the source or not. Press yes. SPK will be created and you can see app.
  
 ===== How can I get the Display Size? ===== ===== How can I get the Display Size? =====
Line 21: Line 37:
 <code>btn.SetOnTouch(function({myCallback(arg1,arg2...)}))</code> to pass arguments to the callback, but it doesn't work. <code>btn.SetOnTouch(function({myCallback(arg1,arg2...)}))</code> to pass arguments to the callback, but it doesn't work.
  
-Sorry, DroidScript does not support anonymous functions as callback parameters.\\  +Sorry, DroidScript does support anonymous functions as callback parameters only beginning from version >= 1.4.5.\\  
-This is due to a limitation within the Android WebView->Java bridge.+This was due to a limitation within the Android WebView->Java bridge.
  
 =====How Do I Implement In-app-purchases in my DroidScript app?===== =====How Do I Implement In-app-purchases in my DroidScript app?=====
 +This information is copied from a post by Dave Smart at https://groups.google.com/d/msg/androidscript/H0fj_jqGdE0/JiI-Scz-2ZwJ
 +
 +Sorry this is not documented properly yet, but here are some code snippets that might help those trying to use In App Purchasing:-
 +
 +You will need to read the Google play IAP licensing info and setup IAP products in your dev console to use this.. although you can use Google's test ids to practice with at first.
 +
 +Here is how to prepare for IAP:-
 +<code>
 +var playStore=null, purchases=[];
 +
 +function OnStart()
 +{
 +   DrawLayout();
 +   :
 +   //Create Google Play object.
 +   playStore = app.CreatePlayStore();
 +   :
 +}
 +</code>
 +
 +
 +Here is how to buy an item:-
 +<code>
 +//Purchase an IAP item.
 +function PurchaseItem()
 +{
 +        //Start the purchase process.
 +        var prodId = "myproductcode";
 + playStore.Purchase( prodId, "xbxrandomxbx", OnPurchased );
 +}
 +
 +//Handle completed purchase.
 +function OnPurchased( prodId )
 +{
 +    //Update purchase items array.
 +    purchases[prodId] = true;
 +    
 +    alert( "OnPurchased" + prodId );
 +}
 +</code>
 +
 +Here is how to check for purchased items:-
 +<code>
 +//Check items are licensed.
 +function CheckLicenses()
 +{
 +    //Check licenses after delay (allows app to finish starting up).
 +    setTimeout( "playStore.GetPurchases(OnLicenses)", 1000 );
 +}
 +
 +//Save licenses to an array.
 +function OnLicenses( items )
 +{
 +    for( var i=0; i<items.length; i++ )
 +        purchases[items[i].productId] = (items[i].purchaseState==0);
 +}
 +</code>
 +
 +Here is how to get prices of items:-
 +<code>
 +//Get prices from Google Play.
 +//(Takes a comma separated list of prod ids)
 +function GetPrices( prodIDs )
 +{
 +    //Get product info from Google Play.
 +    //(Only paid items will be listed in OnStoreInfo)
 +    playStore.GetBillingInfo( prodIDs, OnStoreInfo );
 +}
 +
 +//Show Play Store prices.
 +function OnStoreInfo( items )
 +{
 +    //Show prices.
 +    for( var i=0; i<items.length; i++ )
 +    {
 +        var prodId = items[i].productId;
 +        var price = items[i].price;
 +        alert( prodId + " = " + price );
 +    }
 +}
 +</code>
 +
 +=====How Do I Add Advertisements to my App?=====
 +If your ad network provides HTML ads( which almose every one of them does ) then you can use it in WebView.
 +For  HTML ads, your network will give you link and you have to use it in <script src> tag.(Chris Hopkins told this useful information) Something like this :
 +<code>
 +webView.LoadHtml('<html><head><script src="Link"></script></head></html>');
 +</code>
 +
 +  
getting_started/faq.1428681064.txt.gz · Last modified: 2015/04/10 23:51 (external edit)