0
如何檢查設備的能力android cordova?任何人都可以提供代碼?上下文變量錯誤..顯示上下文變量在這個位置爲空,而試圖運行設備中的代碼顯示力關閉!我試圖檢查相機capability..please幫助...在此先感謝如何檢查設備能力
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.");
}
}
}