【原】 COCOS2D—LUA 获取剪贴板内容
android下:
local luaj = require ("framework.luaj")
local ok,ret = luaj.callStaticMethod("com/test/pokemon/testClass","getClipText",nil,"()S") 参数1:类名 参数2:静态方法 参数3:需要传的参数 参数4:返回类型 ()带表传递参数为空 S返回为string类型
public static String getClipText()
{
((Pokemon)Pokemon.getContext()).runOnUiThread(
new Runnable()
{
public void run()
{
ClipData localClipData = ((ClipboardManager)Pokemon.getContext().getSystemService("clipboard")).getPrimaryClip();
if (localClipData != null)
{
ClipData.Item localItem = localClipData.getItemAt(0);
if ((localItem != null) && (localItem.getText() != null))
AppUtils.str2 = localItem.getText().toString();
}
}
});
return str2;
}
IOS下:
[[UIPasteboard generalPasteboard] string]
参考文档:http://dualface.github.io/blog/2013/01/01/call-java-from-lua/