Archive for 'Nbsp'

Error Checking in Corona

The biggest annoyance and pitfall is basic errors caused by typos. In Lua, unlike other languages, you don’t need to declare variables.
If you use a variable without declaring it, it becomes a global. This can cause uncaught errors if you have a typo. Consider the following:
local levelComplete = true
if LevelComplete == true then

print(“you won”)

end
Notice the typo, ‘LevelComplete’ with a capital ‘L’. Lua/Corona won’t catch this and instead make ‘LevelComplete’ a new global, and of course it will never be set to true, and so you could never win this game!
To get around the problem you can add the following code to the beginning of your main.lua to catch these issues. This will prevent ALL globals from being declared, and so would catch the above by displaying an error.
function declare (name, initval)

rawset(_G, name, initval or false)?

end
setmetatable(_G, {

__newindex = function(_ENV, var, val)

if var ~= “tableDict” then

error((“attempt to set undeclared global\”%s\”"):format(tostring(var)), 2)

else?

rawset(_ENV, var, val)

end

end,
__index = function(_ENV, var, val)

if var ~= “tableDict” then?

error((“attempt to read undeclared global\”%s\”"):format(tostring(var)), 2) else

rawset(_ENV, var, val)?

end?

end,

})

 

If you do want to use a Global then you need to use declare as below:

declare(“Levels”)

declare(“BonusLevels”)

To rotate an object in corona

The rotation occurs around the object’s reference point. The default reference point for most Display Objects is center.

Syntax:

deltaAngle
number: degrees to rotate. A positive number rotates the object clockwise and a negative number rotates the object counter-clockwise.

Incoming search terms:

  • how to rotate an object in corona

Sencha Datastore connection to PHP

Create a Table “Employee” with following fields in Mysql:

ID, FirstName, LastName, Salary

After that you need to create a php file “data-file.php” with script for listing table contents.

Then we need to create a Datastore to connect our php file data_file.php:

 

Incoming search terms:

  • sencha store php

Creating Resources from IDs Dynamically

To Make Bitmap from the Resource

 

Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.icon);

 

When a new image is taken through a camera, you can add that image to the array/list and update the adapter using notifyDataSetChanged.

 

Bitmap[] images = { BitmapFactory.decodeResource(getResources
(),R.drawable.hm1),BitmapFactory.decodeResource(getResources
(),R.drawable.hm2),BitmapFactory.decodeResource(getResources(),R.drawable.hm3)};

 

Incoming search terms:

  • array bitmapfactory decoderesource(getresources() r drawable icon)

Useful methods to handle exceptions in PHP

getMessage() 

gets the exception’s message

 
 

getCode(

returns a numerical code that represents the exception

 
 

getFile()

returns the file where the exception was thrown

 
 

getLine() 

returns the line number in the file where the exception was thrown

 
 

getTrace()

returns the an array of the backtrace() before the exception was thrown

 
 

getPrevious() 

returns the exception thrown before the current one, if any

 
 

getTraceAsString()

returns the backtrace() of an exception as a string instead of an array

 
 

__toString() 

returns the whole exception as a string. Is overrideable.

 
 

 
 

Often, you want to supply some criteria to search on. You can do this by supplying this information as part of the Intent’s extras. The ACTION_WEB_SEARCH Intent specifically uses the SearchManager.QUERY extra field for the search criteria. For example, to perform the Google search on pygmy goats, you configure the SearchManager.QUERY extra and launch the Browser as follows:

 

Intent search = new Intent(Intent.ACTION_WEB_SEARCH);  

search.putExtra(SearchManager.QUERY, “iPhone 4S”);  

startActivity(search);  

 
 

Android uses Uri (Uniform Resource Identifier) objects to identify the unique location of a piece of data. Uri objects are often used to specify the data that an Intent is supposed to use. In this case, we will create a Uri object from a web URL using the parse() method:

 
 

Uri uriUrl = Uri.parse(“http://www.schogini.com/”);  

 
 

You can view HTML content using the following Intent: android.content.Intent.ACTION_VIEW. Begin by creating an Intent of this type and specifying the URI you created above, as follows, within your Button click handler:

 
 

Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);  

 
 

When you launch this Intent, any applications that can display web will be able to handle this request. Once you have set the type data for the Intent, you can call the startActivity() method, passing in your Intent:

startActivity(launchBrowser);  

 
 

When you click on this button, the Browser application (which generally handles HTML content display) is launched to the website you provided.

Sending http request to a remote server in sencha

Sending http request to a remote server in sencha:

where,

url: The URL to which to send the request, or a function to call which returns a URL string

params:  parameters to the request

 

callback :  The function to be called upon receipt of the HTTP response. The callback is called regardless of success or failure and is passed the following parameters:

options: The parameter to the request call.

success: True if the request succeeded.

response: The XMLHttpRequest object containing the response data.

 

Incoming search terms:

  • send http request in sencha

Customizing Android Fonts – Typeface

 

There are three different default typefaces which are known as the Droid family of fonts: sans, monospace and serif. You can specify any one of them as the value for the android:typeface attribute in the XML declaration of a component that supports text styling, such as TextView. Here’s an example of all three typefaces in action:

Setting IdleTimer in Corona

Here is the code that helps you set the IdleTimer in Corona

By default, the IdleTimer of a system will be set to true. If the IdleTimer is active then it dims the screen and eventually will make the device to sleep mode.

Incoming search terms:

  • corona android system sleep
Page 1 of 712345...Last »