This shows you the differences between two versions of the page.
getting_started:faq [2015/07/15 15:28] sandudhate [How Do I Add Advertisements to my App?] |
getting_started:faq [2017/10/21 14:57] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Frequently Asked Questions ====== | ||
- | This faq is expected to grow significantly over time. Please feel free to add to it or correct any mistakes. | ||
- | ===== How do I set an icon for my app? ===== | ||
- | To see a personalized icon for your script in the program overview of DroidScript, | ||
- | e.g. if your script is called " | ||
- | |||
- | The easiest way to do this uses the **[[getting_started: | ||
- | ===== What is an SPK and how do I use it? ===== | ||
- | An SPK is a DroidScript package. | ||
- | |||
- | To use an SPK, you need to import it into DroidScript. | ||
- | |||
- | ===== How can I get the Display Size? ===== | ||
- | I am trying to get the width and height (in pixels) that I have available to work with in the application. Is there a way to get the values? | ||
- | |||
- | Have you tried using app.GetDisplayWidth() & app.GetDisplayHeight()? | ||
- | |||
- | ===== Can I use an anonymous function as a callback? ===== | ||
- | I am trying to use an anonymous function in a button event handler: | ||
- | < | ||
- | |||
- | Sorry, DroidScript does not support anonymous functions as callback parameters.\\ | ||
- | This is due to a limitation within the Android WebView-> | ||
- | |||
- | =====How Do I Implement In-app-purchases in my DroidScript app?===== | ||
- | This information is copied from a post by Dave Smart at https:// | ||
- | |||
- | 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' | ||
- | |||
- | Here is how to prepare for IAP:- | ||
- | < | ||
- | var playStore=null, | ||
- | |||
- | function OnStart() | ||
- | { | ||
- | | ||
- | : | ||
- | // | ||
- | | ||
- | : | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | Here is how to buy an item:- | ||
- | < | ||
- | //Purchase an IAP item. | ||
- | function PurchaseItem() | ||
- | { | ||
- | //Start the purchase process. | ||
- | var prodId = " | ||
- | playStore.Purchase( prodId, " | ||
- | } | ||
- | |||
- | //Handle completed purchase. | ||
- | function OnPurchased( prodId ) | ||
- | { | ||
- | //Update purchase items array. | ||
- | purchases[prodId] = true; | ||
- | | ||
- | alert( " | ||
- | } | ||
- | </ | ||
- | |||
- | Here is how to check for purchased items:- | ||
- | < | ||
- | //Check items are licensed. | ||
- | function CheckLicenses() | ||
- | { | ||
- | //Check licenses after delay (allows app to finish starting up). | ||
- | setTimeout( " | ||
- | } | ||
- | |||
- | //Save licenses to an array. | ||
- | function OnLicenses( items ) | ||
- | { | ||
- | for( var i=0; i< | ||
- | purchases[items[i].productId] = (items[i].purchaseState==0); | ||
- | } | ||
- | </ | ||
- | |||
- | Here is how to get prices of items:- | ||
- | < | ||
- | //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< | ||
- | { | ||
- | var prodId = items[i].productId; | ||
- | var price = items[i].price; | ||
- | alert( prodId + " = " + price ); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | =====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. Something like this : | ||
- | < | ||
- | webView.LoadHtml('< | ||
- | </ | ||
- | |||
- | |