我是Android NDK的新手,我不了解静态库和共享库之间的区别.它们是什么,何时我会选择一种类型而不是另一种?
有没有办法在visual-c ++项目中获取文档(如javadoc)?
我正在使用visual studio 2010.
谢谢!
我已经开始在我的应用程序中使用Architecture Components,我仍然在学习如何使用它.
在我的应用程序中,我有一个活动按顺序显示不同的碎片.在其中一些我需要与后台服务进行通信,以便从外部BLE传感器接收数据.由于我需要在多个片段中与服务进行交互,我想知道ViewModel是否是进行绑定的正确位置.我环顾四周,但没有找到答案.
在ViewModel中绑定服务有什么问题吗?
android android-service android-viewmodel android-architecture-components
我很确定这是一个愚蠢的问题,但它让我疯狂..
我怎么能在控制台上打印一个TCHAR阵列?
DWORD error = WSAGetLastError();
TCHAR errmsg[512];
int ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, error, 0, errmsg, 511, NULL);
Run Code Online (Sandbox Code Playgroud)
我需要打印errmsg ...
两年前,我在android-7(Eclair)上开发了一个增强现实框架.由于AR应用程序是计算密集型任务,因此我开发了Java活动使用的JNI c ++库来呈现和注册虚拟环境.在Java中获取的传感器读数被传递到下划线c ++库以计算虚拟环境的注册.三维对象由从GLSurfaceView调用的本机绘制函数呈现.这导致了大量的JNI调用.
现在我想将应用程序移植到android-15(Ice Cream Sandwich).从android-9(Gingerbread)开始, Android允许使用NativeActivity.
我想了解哪种是开发AR应用程序的更好方法.由于每个JNI调用都会引入开销,因此避免它们会好得多.是否可以使用NativeActivity?我没有找到解释NativeActivity如何工作的详尽指南,但是阅读本文档似乎无论如何都会导致很多JNI调用.是否有任何架构文档可以解释NativeActivity的工作原理?NativeActivity只是一个"JNI包装器"来避免java代码吗?关于性能,使用NativeActivity而不是像以前那样使用JNI库有什么优势吗?
非常感谢.
在我的项目中,我有一个库模块和一个使用它的应用程序模块。在这两个模块中,我对 Android 架构组件库具有相同的 gradle 依赖项:
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.0.0"
implementation "android.arch.lifecycle:common-java8:1.0.0"
// Room
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
Run Code Online (Sandbox Code Playgroud)
在我的库模块中,我定义了一个 User 实体
@Entity(tableName = "users",
indices = {@Index(value = {"firstName", "lastName"})})
public class User {
public enum ROLE {
...
}
public enum FEEDBACK_LEVEL {
...
}
@PrimaryKey
public int id;
@TypeConverters(UserConverters.class)
ROLE role;
@TypeConverters(UserConverters.class)
FEEDBACK_LEVEL feedbackLevel;
public String firstName;
public String lastName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public …Run Code Online (Sandbox Code Playgroud) 我需要检索手机的方向.目前我写了这个:
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()){
case Sensor.TYPE_MAGNETIC_FIELD:
this.mag_vals = event.values.clone();
this.sensorReady = true;
break;
case Sensor.TYPE_ACCELEROMETER:
this.acc_vals = event.values.clone();
break;
}
if (this.mag_vals != null && this.acc_vals != null && this.sensorReady) {
this.sensorReady = false;
float[] R = new float[ProjectConstants.SIZE_MATRIX];
float[] I = new float[ProjectConstants.SIZE_MATRIX];
SensorManager.getRotationMatrix(R, I, this.acc_vals, this.mag_vals);
SensorManager.getOrientation(R, this.actual_orientation);
...
Run Code Online (Sandbox Code Playgroud)
如果我将手机放在平面上并将其旋转到表面上,此代码可让我获取手机的方向.
我不明白的是,如果我向上移动手机的值this.actual_orientation[0],即[此处] [1]所述的zed轴上的旋转,虽然没有旋转,但值会增加.
有人知道会发生什么吗?
编辑
另一件奇怪的事......
我在办公室里尝试了我的应用程序,它有我之前描述的奇怪的行为..我在同一个办公室(同样的情况)尝试了一个指南针应用程序,我从市场上取得它与我的相同的行为..当我我把电话向上移动了一致的价值变化..我在同一个办公室(同样的情况)尝试了i-phone罗盘,它没有那种奇怪的行为!
然后,当我到家时,我尝试了两个,我的应用程序和我的Android手机的指南针应用程序,他们工作!!即使我向上移动手机价值稳定...
非常感谢.
[1]:http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation(float [],float [])
我尝试写入控制台时遇到问题.
在插件项目中,我开发了一个自定义构建,可以使用我开发的命令通过菜单调用.最初构建是在launch我的类的方法中调用的,它实现了ILaunchConfigurationDelegate.
...
String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
Process compilerProcess = DebugPlugin.exec(commandLine, new File(project.getLocation().toString()));
@SuppressWarnings("rawtypes")
Map processAttributes = new HashMap();
processAttributes.put(IProcess.ATTR_PROCESS_TYPE, "XVR");
IProcess dbgProcess = DebugPlugin.newProcess(launch, compilerProcess, "XVR Compiler", processAttributes);
try {
compilerProcess.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(compilerProcess.exitValue() != 0) return false;
launch.removeProcess(dbgProcess);
Run Code Online (Sandbox Code Playgroud)
当进行构建,该过程的输出被输出到控制台上,并与它实现IConsoleLineTracker到突出了误差的类解析.
我将构建方法移到实现ILaunchConfigurationDelegate的类之外,并且不再打印控制台.两种情况之间的唯一区别是如何提供对象iLaunch.新的构建方法如下
...
String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
Process compilerProcess = DebugPlugin.exec(commandLine, new File(prj.getLocation().toString()));
ILaunch xvrLaunch = XVRUtils.getXVRLaunch();
Map<String, String> processAttributes = new HashMap<String, String>(); …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 Eclipse 产品,我需要将文件扩展名关联到我的编辑器。我遵循了几个示例(例如this和 this),但编辑器似乎曾经收到过 SWT OpenDocument 事件。
PlatformUI.createAndRunWorkbench()如 fileAssociation 示例中所述,我创建了一个 eventListener 类来处理 SWT.OpenDocument 事件,并在调用该方法之前将其添加到我的 Application 类中显示
public Object start(IApplicationContext context) throws Exception {
Object args = context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
OpenDocumentEventProcessor eProc = new OpenDocumentEventProcessor();
Display display = PlatformUI.createDisplay();
display.addListener(SWT.OpenDocument, eProc);
try{
if(!handleWorkspace(display)){
System.exit(0);
return IApplication.EXIT_OK;
}
int returnCode = PlatformUI.createAndRunWorkbench(display, new XVRWorkbenchAdvisor(args, eProc));
Run Code Online (Sandbox Code Playgroud)
在产品文件中,我添加了以下程序参数:
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-name
XVR Studio Developer
Run Code Online (Sandbox Code Playgroud)
如果我在一个新的空 RCP 项目中使用相同的代码,它就会像一个魅力一样工作。
我不知道哪个可能是问题所在..
你能帮助我吗?
多谢!!
我在本机应用程序中链接 STL 时遇到一些问题。map::operator[] 和 map::insert 的链接失败,而其他映射函数的链接成功。我的 Application.mk 是:
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions -frtti
APP_CPPFLAGS += -g3
APP_CPPFLAGS += -DDEBUG
APP_ABI := armeabi-v7a
APP_PLATFORM:=android-14
NDK_TOOLCHAIN_VERSION:=4.6
Run Code Online (Sandbox Code Playgroud)
本机代码包含两个文件夹级别。我为每个内部文件夹创建了一个 Android.mk 文件来编译并生成静态库。我在最深的文件夹中使用 std::map 。Android.mk 如下所示:
TEMP_PATH_REG := $(call my-dir)
LOCAL_PATH := $(TEMP_PATH_REG)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(TEMP_PATH_REG)
include $(CLEAR_VARS)
LOCAL_MODULE := registration
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../glm/
LOCAL_SRC_FILES := registration_factory.cpp \
inertial.cpp
LOCAL_LDLIBS := -llog -landroid -lEGL
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_STATIC_LIBRARY)
$(call import-module,android/native_app_glue)
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,我收到以下错误:
~/.android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libregistration.a(registration_factory.o): in function std::_Rb_tree<int, std::pair<int const, xmar::IRegistration*>, std::_Select1st<std::pair<int …Run Code Online (Sandbox Code Playgroud) 我是XText的新手.
当您使用的Xtext,你可以指定一个第二语法和使用,因为它是说,它宣称的定义定义语法在这里:
grammar org.eclipse.xtext.example.Domainmodel with org.eclipse.xtext.common.Terminals
Run Code Online (Sandbox Code Playgroud)
在Xtext中,每个语法都有一个唯一的名称,就像公共Java类需要反映Java类路径中文件的位置一样.在我们的例子中,语法文件位于/org/eclipse/xtext/example/Domainmodel.xtext中,因此语法的名称是org.eclipse.xtext.example.Domainmodel.该语句的第二部分(使用org.eclipse.xtext.common.Terminals)声明,该语法重用并覆盖指定语法中的规则.org.eclipse.xtext.common.Terminals是Xtext附带的库语法,它预定义了最常用的终端规则
我正在开发一个XText插件,我想在一个单独的文件中定义我自己的终端符号.可能吗?我怎样才能做到这一点?
我尝试创建一个新的Xtext文件并将其附加到org.eclipse.xtext.common.Terminals之后并添加我的但是两个解决方案都不能编译.
谢谢.
编辑
如果我在同一个项目中使用两个xtext文件,一个用于语法,一个用于语法的终端,我得到以下异常启动mwe2文件:
java.lang.IllegalStateException:解析'classpath:/org/xvr/language/sh/ShaderDsl.xtext'时出现问题:[XtextLinkingDiagnostic:null:1无法解析对语法'org.xvr.language.sh.ShTerminal'的引用. ,XtextLinkingDiagnostic:null:9无法解析对AbstractRule'ID'的引用.,TransformationDiagnostic:null:14无法创建数据类型INVARIANT(ErrorCode:NoSuchTypeAvailable),TransformationDiagnostic:null:17无法创建数据类型PRECISION(ErrorCode:NoSuchTypeAvailable),TransformationDiagnostic: null:19无法创建数据类型HIGH_PRECISION(ErrorCode:NoSuchTypeAvailable),TransformationDiagnostic:null:20无法创建数据类型MEDIUM_PRECISION(ErrorCode:NoSuchTypeAvailable),TransformationDiagnostic:null:21无法创建数据类型LOW_PRECISION(ErrorCode:NoSuchTypeAvailable)]
两个xtext文件是:
语法
grammar org.xvr.language.sh.ShaderDsl with org.xvr.language.sh.ShTerminal //org.eclipse.xtext.common.Terminals
generate shaderDsl "http://www.xvr.org/language/sh/ShaderDsl"
....
Run Code Online (Sandbox Code Playgroud)
和语法的终端
grammar org.xvr.language.sh.ShTerminals with org.eclipse.xtext.common.Terminals
generate shTerminals "http://www.xvr.org/language/sh/ShTerminals"
terminal Test : 'test';
Run Code Online (Sandbox Code Playgroud) android ×6
android-ndk ×3
c++ ×3
eclipse ×3
java ×3
android-architecture-components ×2
visual-c++ ×2
android-room ×1
eclipse-rcp ×1
grammar ×1
linker ×1
magnetometer ×1
orientation ×1
plugins ×1
process ×1
sensor ×1
stl ×1
swt ×1
xtext ×1