源码如下:
- uses
- Androidapi.JNI.Os,
- Androidapi.JNIBridge;
-
- function GetVibratorArray(const AIntArr: array of Int64): TJavaArray<Int64>;
- var
- LIndex: Integer;
- begin
- Result := TJavaArray<Int64>.Create(Length(AIntArr));
- for LIndex := Low(AIntArr) to High(AIntArr) do
- Result.Items[LIndex] := AIntArr[LIndex];
- end;
-
- procedure VibratorTest;
- var
- LVibratorObj: JObject;
- LVibrator: JVibrator;
- LJavaArray: TJavaArray<Int64>;
- begin
-
-
-
-
-
- LVibratorObj := SharedActivity.getSystemService(
- TJContext.JavaClass.VIBRATOR_SERVICE);
- LVibrator := TJVibrator.Wrap((LVibratorObj as ILocalObject).GetObjectID);
-
-
- if not LVibrator.hasVibrator then
- begin
- ShowMessage('手机不支持震动');
- Exit;
- end;
-
-
-
-
-
-
- LJavaArray := GetVibratorArray([500, 1000, 2000, 3000]);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- end;
http://blog.csdn.net/flcop/article/details/13290779
|
请发表评论