2

我正在尝试使用这个创建一个phonegap插件 -

https://github.com/dixon1e/ARviewer-phoneGap

我在我的插件操作方法中使用这个调用 -

if(action.equalsIgnoreCase("open")) {  
// campreview.onCreate(null);  
Log.d(PLUGIN_NAME, "Inside Open");  
cordova.getActivity().runOnUiThread(new Runnable(){   
public void run() {  
Log.d(PLUGIN_NAME, "Start Camera");  
Context context = cordova.getActivity().getApplicationContext();  
Intent intent = new Intent(context,CameraActivity.class);  
cordova.getActivity().startActivity(intent);  
callbackContext.success();  
}  
});  

我创建了一个这样的 CameraActivity.java 文件-

private final static String tag = "CameraActivity";  
@Override  
public void onCreate(Bundle savedInstanceState) {  
Log.d(tag, "Inside onCreate CameraActivity");  

super.onCreate(savedInstanceState);   

//  arviewer.arurl();  
setContentView(R.layout.main);  
RelativeLayout preview = (RelativeLayout)findViewById(R.id.phonegap_container);  

// Create an instance of Camera  
//mCamera = getCameraInstance();  
if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {  
Toast.makeText(this, "No Camera on this Device", Toast.LENGTH_LONG).show();  
} else {  
cameraID = findBackFacingCamera();  
if(cameraID == 0){  
    mCamera = Camera.open(cameraID);  
} else {  
    Toast.makeText(this, "No Back Camera Found", Toast.LENGTH_LONG).show();  
}  

}  

// Create our Preview view and set it as the content of our activity.  
mPreview = new CameraSurfacePreview(this, mCamera);  
preview.setBackgroundColor(Color.TRANSPARENT);  
preview.addView(mPreview);  
preview.setFocusable(false);  
/*  FrameLayout preview = (FrameLayout) findViewById(R.id.phonegap_container);  
preview.setBackgroundColor(Color.TRANSPARENT);  
preview.addView(mPreview);  
preview.setFocusable(false); */  

}  

private int findBackFacingCamera() {  
int cameraId = -1;  
// Search for the Back facing camera  
int numberOfCameras = Camera.getNumberOfCameras();  
for (int i = 0; i < numberOfCameras; i++) {  
CameraInfo info = new CameraInfo();  
Camera.getCameraInfo(i, info);  
if (info.facing == CameraInfo.CAMERA_FACING_BACK) {  
Log.d(tag, "Camera found, cameraID =" +i);  
cameraId = i;  
break;  
}  
}  
return cameraId;  
}  
}  

运行代码后,摄像头以预览模式打开,但没有显示显示 POI 的 webview 数据,当我按下后退键时,它会显示 Webview 数据。我想我必须在我的 onCreate 函数中添加以下代码来解决这个问题,但是我将如何添加这段代码。如果我尝试添加它显示我 appView 未声明。

View html = (View)appView.getParent();  
html.setBackgroundColor(Color.TRANSPARENT);  
view.addView(html, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));  
appView.setBackgroundColor(Color.TRANSPARENT);  
// Avoid the focus on click events  
appView.setFocusable(false);  
4

1 回答 1

0

我建议您为您的项目使用 wikiitude SDK。

http://www.wikitude.com/products/wikitude-sdk/

于 2014-03-09T16:31:25.440 回答