0
我正在嘗試爲Android Vibration製作本機擴展程序。我找到的每個開源擴展只使用vibrate(duration)
而不是vibrate(pattern, repeat)
和vibrate.cancel()
如何在AIR to Android Native擴展中將數組作爲'long'接收?
我需要能夠傳遞一個patten和cancel函數。
我可以讓vibration(duration)
正常工作,沒有問題。有一個簡單的args[1].getAsInt();
方法供我使用。但是,沒有.getAsArray
或.getAsLong
。
我找到了一種叫做FREArray的東西,但我真的不知道如何使用它。因此,我的問題是,用AS3函數,我可以傳遞一個數組(模式)和一個int(重複計數)我怎樣才能接收Android端的數組?我沒有任何麻煩接受重複的整數。
這是我到目前爲止的工作,但由於它看起來像我沒有正確使用它的錯誤。有什麼建議麼?
public FREObject call(FREContext context, FREObject[] args) {
VibrateExtensionContext vibrate(pattern, repeat)ExtensionContext) context;
long[] pattern;
int repeat = 0;
try {
pattern = FREArray.newArray(args[0]); //this is where im stuck
//it would be ideal if there was something like this..
//pattern = args[0].getAsLong(); but this doesnt exist
repeat = args[1].getAsInt(); //this works fine
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FRETypeMismatchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FREInvalidObjectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FREWrongThreadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
vibExtContext.androidVibrator.vibrate(pattern, repeat);
return null;
}