本文整理匯總了Java中com.ansca.corona.CoronaActivity類的典型用法代碼示例。如果您正苦於以下問題:Java CoronaActivity類的具體用法?Java CoronaActivity怎麽用?Java CoronaActivity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CoronaActivity類屬於com.ansca.corona包,在下文中一共展示了CoronaActivity類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: LuaLoader
import com.ansca.corona.CoronaActivity; //導入依賴的package包/類
/**
* Creates a new object for displaying banner ads on the CoronaActivity
*/
public LuaLoader() {
CoronaActivity activity = CoronaEnvironment.getCoronaActivity();
// Validate.
if (activity == null) {
throw new IllegalArgumentException("Activity cannot be null.");
}
}
示例2: invoke
import com.ansca.corona.CoronaActivity; //導入依賴的package包/類
/**
* This method is called when the Lua function is called.
* <p>
* Warning! This method is not called on the main UI thread.
* @param luaState Reference to the Lua state.
* Needed to retrieve the Lua function's parameters and to return values back to Lua.
* @return Returns the number of values to be returned by the Lua function.
*/
@Override
public int invoke( final LuaState luaState )
{
try
{
// Fetch the Lua function's first argument.
// Will throw an exception if it is not of type string.
String popupName = luaState.checkString( 1 );
String packageName = luaState.checkString( 2 );
// Get the corona activity
CoronaActivity coronaActivity = null;
if ( CoronaEnvironment.getCoronaActivity() != null )
{
coronaActivity = CoronaEnvironment.getCoronaActivity();
}
// Does the package exist
boolean doesTargetPackageExist = false;
// If the corona activity is alive
if ( coronaActivity != null )
{
doesTargetPackageExist = doesPackageExist( coronaActivity, packageName );
}
// Push the result
luaState.pushBoolean( doesTargetPackageExist );
}
catch( Exception ex )
{
// An exception will occur if given an invalid argument or no argument. Print the error.
ex.printStackTrace();
}
// Return 1 since this Lua function returns 1 value.
return 1;
}
示例3: executeUsing
import com.ansca.corona.CoronaActivity; //導入依賴的package包/類
@Override
public void executeUsing( CoronaRuntime runtime )
{
try
{
// Fetch the Corona runtime's Lua state.
final LuaState L = runtime.getLuaState();
// Dispatch the lua callback
if ( CoronaLua.REFNIL != fLuaListenerRegistryId )
{
// Setup the event
CoronaLua.newEvent( L, "popup" );
// Event type
L.pushString( "social" );
L.setField( -2, "type" );
// Set the event.action key based on whether the message was sent, or cancelled
switch (fResultCode) {
case CoronaActivity.RESULT_CANCELED:
// Event action
L.pushString( "cancelled" );
L.setField( -2, "action" );
break;
case CoronaActivity.RESULT_OK:
// Event action
L.pushString( "sent" );
L.setField( -2, "action" );
break;
}
// Dispatch the event
CoronaLua.dispatchEvent( L, fLuaListenerRegistryId, 0 );
}
}
catch ( Exception ex )
{
ex.printStackTrace();
}
}