如何检查 android cordova 的设备功能?谁能提供代码?上下文变量错误..显示上下文变量在此位置为空,同时尝试在显示强制关闭的设备中运行代码!我正在尝试检查相机功能..请帮助...提前致谢
package com.troubling.android;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.content.Context;
import android.util.Log;
public class Echo extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws
JSONException
{
Context context = null;
PackageManager pm = this.cordova.getActivity().getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
Log.i("camera", "This device has camera!");
}
else{
Log.i("camera", "This device has no camera!");
}
return false;
}
private void echo(String message, CallbackContext callbackContext) {
if (message != null && message.length() > 0) {
callbackContext.success(message);
} else {
callbackContext.error("Expected one non-empty string argument.");
}
}
}