标签: native

Crossbrowser替代html = $('html')

这样写是不是太蹩脚了?

var html = $('html');
Run Code Online (Sandbox Code Playgroud)

似乎html等于$(window)$(document)

它如何被crossbrowser原生javascript取代?

html javascript jquery native window

2
推荐指数
1
解决办法
58
查看次数

使用JNI依赖项,应用程序和Eclipse插件进行Gradle构建

我正在尝试使用Gradle的示例LWJGL应用程序。LWJGL在jar lwjgl-platform-2.8.5-natives-windows.jar中具有OpenGL和OpenAL的本机绑定,但是,Gradle似乎无法识别这一事实。

应用程序插件的distZip任务正确地将所有jar文件复制到zip的lib目录中,但是,在.bat文件中,它仅将上述本地jar放在类路径中,而没有将其作为显式本地传递给Java。

同样,Eclipse项目生成也无法设置给定依赖项的“本机库位置”。

是否有任何官方解决方案可将本机库正确添加到生成的应用程序或Eclipse项目中;如果没有,围绕此限制是否有不错的解决方法?

我的gradle.build:

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'

sourceCompatibility = 1.7

mainClassName = 'org.lwjgl.examples.Game'

repositories {
    mavenCentral();
}

dependencies {
    compile group: 'com.google.guava', name: 'guava', version: 'latest.release'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: 'latest.release'
    compile group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: 'latest.release'

    testCompile group: 'com.jayway.awaitility', name: 'awaitility', version: 'latest.release'
    testCompile group: 'junit', name: 'junit', version: 'latest.release'
    testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: 'latest.release'
    testCompile group: 'org.mockito', name: 'mockito-core', version: 'latest.release'
}

jar {
    baseName …
Run Code Online (Sandbox Code Playgroud)

eclipse java-native-interface native lwjgl gradle

2
推荐指数
1
解决办法
5136
查看次数

在使用Java本机接口时,如何解决"致命:重定位仍然存在于可分配但不可写的部分"?

我正在尝试在Java代码中调用C函数.我有这个hava代码.

public class JavaToC {

    public native void helloC();

    static {
        System.loadLibrary("HelloWorld");
    }

    public static void main(String[] args) {
        new JavaToC().helloC();
    }
}
Run Code Online (Sandbox Code Playgroud)

.我编译它然后创建头文件.然后制作以下HelloWorld.c文件.

#include <stdio.h>
#include <jni.h>
#include "JavaToC.h"
JNIEXPORT void JNICALL Java_JavaToC_helloC(JNIEnv *env, jobject javaobj)
{
  printf("Hello World: From C");
  return;
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用"gcc -o libHelloWorld.so -shared -I/usr/java/include -I/usr/java/include/solaris HelloWorld.c -lc"进行编译,但它给出了以下结果.

Text relocation remains                     referenced
    against symbol          offset  in file
.rodata (section)                   0x9         /var/tmp//cc.GaGrd.o
printf                              0xe         /var/tmp//cc.GaGrd.o
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned …
Run Code Online (Sandbox Code Playgroud)

c java java-native-interface solaris native

2
推荐指数
1
解决办法
4289
查看次数

VB.Net - 检查文件是否为.net二进制文件

如何查看文件,如何查看VB.Net

C:\文件\将Test.exe

是.net二进制文件还是原生二进制文件?

c# vb.net native managed file

2
推荐指数
1
解决办法
994
查看次数

存储库-在本机查询中按订单排序不起作用

我有一个spring数据JPA存储库(位于postgres db上),我有时需要使用nativeQuery = true选项来使用本机查询。

但是,在当前情况下,我需要传递一个order字段,并且这样做是这样的:

电话..

targetStatusHistoryRepository.findSirenAlarmTimeActivation([uuid,uuid2],"activation_name DESC", 0, 10)
Run Code Online (Sandbox Code Playgroud)

..回购方法

@Query(
        nativeQuery = true,
        value = """select
                     a.name as activation_name,
                     min(transition_from_active_in_millis),
                     max(transition_from_active_in_millis),
                     avg(transition_from_active_in_millis) from target_status_history t, activation_scenario a
                     where t.activation_uuid=a.activation_scenario_id and t.transition_from_active_in_millis > 0 and t.activation_uuid in (:activationUUIDs) group by a.name,t.activation_uuid
                     order by :orderClause offset :offset limit :limit """
)
List<Object[]> findSirenAlarmTimeActivation(@Param("activationUUIDs") List<UUID> activationUUIDs,
                                                              @Param("orderClause") String orderClause, @Param("offset") int offset, @Param("limit") int limit )
Run Code Online (Sandbox Code Playgroud)

我用DESC写了一个单元测试,然后用ASC调用,反之亦然,看来第一个调用是什么,第二个给出了相同的结果。

sql postgresql spring jpa native

2
推荐指数
1
解决办法
6684
查看次数

如何在离子2应用程序中自动更新谷歌地图上的当前位置

我是离子2原生的初学者.我使用本教程(http://www.joshmorony.com/ionic-2-how-to-use-google-maps-geolocation-video-tutorial/)创建了一个简单的位置跟踪应用程序,我想自动更新用户当前用户旅行时的位置.我搜索了教程或任何来源以了解这一点.但我找不到任何东西.如果有人知道有关自动更新用户位置的信息,ioinc 2请告诉我如何做到这一点或给我一个链接.

这是我的代码

export class MapPage {

  x: number = 0;
  y: number = 0;

  @ViewChild('map') mapElement: ElementRef;
  map: any;

  constructor(public navCtrl: NavController) {
    this.loadMap();
  }

  loadMap() {
    Geolocation.getCurrentPosition().then((position) => {

      let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
      console.log(position.coords.latitude + " " + position.coords.longitude)
      let mapOptions = {
        center: latLng,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }

      this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);

      console.log(this.map);

    }, (err) => {
      console.log(err);
    });
  }

  addInfoWindow(marker, content) {

    let infoWindow = new google.maps.InfoWindow({
      content: …
Run Code Online (Sandbox Code Playgroud)

native geolocation google-maps-api-3 ionic2 angular

2
推荐指数
1
解决办法
1万
查看次数

如何在移动 android/iOs(本机应用程序)中关闭 webview

在我们的应用程序中,在 webview 中打开一个 url 有一种方法可以在检测到某个特定的 url 后关闭 webview。怎么可能关闭webview?我window.close()在 javascript 中尝试过。但无法工作。从 android 或 ios 应用程序有另一种方式。

javascript android native ios

2
推荐指数
1
解决办法
9449
查看次数

React Native Lottie - 动画结束反转

语境

我是 lottie-react-native 的新手,并设法实现了我的第一个动画:

constructor(props) {
    super(props);
    this.state = {
        progress: new Animated.Value(0),
        loop: true
    }
}
componentDidMount() {
    this.animation.play();
}
render() {
const { progress, loop } = this.state;
return (
    <View style={{display:'flex',height:'auto', alignItems: 'center',justifyContent:'center'}}>
    <LottieView
    ref={animation => {
        this.animation = animation;
      }}
    speed={1}
    autoPlay
    source={NOACTIVITY}
    progress={progress}
    loop={loop}
    height={300}
    width={300}
    style={{margin:0,}}
  />
  </View>
)
Run Code Online (Sandbox Code Playgroud)

}

问题

我现在正在尝试使用此动画创建一个循环,向前播放,然后向后播放,然后再次开始该过程。

我做了一些研究并得出结论,这必须使用动画值和时间来完成?我发现了许多向前和向后播放但不一起播放的示例(在 react native docs 中!)。

这可以在组件安装时完成吗?或者它必须是一个单独的功能?

提前致谢!

loops native reactjs lottie

2
推荐指数
1
解决办法
3003
查看次数

如何将字符串数组返回给java JNI

我想将 finalResult 数组返回给 java。任何帮助表示赞赏。

extern "C"
JNIEXPORT void JNICALL
Java_com_testjniproject_MainActivity_AnalyseImageDisplay(JNIEnv *env, jobject instance, jlong sourceImageArray)
{
    Mat &srcInputImg = *(Mat*)sourceImageArray;
    vector<tuple<string, string, int>> result = AnalyseImage(srcInputImg);
    enter code here
    string finalResult[3];
    for (int i=0; i < result.size(); i++)
    {
        cout << get<0>(result[i]) << " : " << get<1>(result[i]) << " With confidence " << get<2>(result[i]) << "%" << endl;
        finalResult[i] = get<1>(result[i]);
    }
}
Run Code Online (Sandbox Code Playgroud)

c++ java-native-interface android opencv native

2
推荐指数
1
解决办法
1435
查看次数

Android:在 Android Studio 中链接外部静态 C/C++ 库

我已经看到很多使用 Cmake 使本机代码在 Android Studio 中工作的答案,但是关于如何将预编译的 C/C++ 库包含到 Android 中的答案并不多。以下是我为尝试使本机库(首先尝试使用 .a)工作而采取的步骤。

1) mylib.c 是我想导入到 Android Studio 中的 C 库

#include "mylib.h"


    int total_foo;

    int foo(float y, float z) { 
    total_foo = y + z;
    return total_foo;

    }
Run Code Online (Sandbox Code Playgroud)

2) mylib.h 是 mylib.c 的头文件

#ifndef _MYLIB_H_
#define _MYLIB_H_

    #define MAX_FOO  20

        struct foo_struct {  
        int x;
        float y;
    };
    typedef struct foo_struct foo_struct;

    extern int total_foo;   

    extern int foo(float y, float z); 

#endif
Run Code Online (Sandbox Code Playgroud)

3) .o 文件的命令(使用带有 make_standalone_toolchain.py 的 NDK)

$CC -o mylib.o …
Run Code Online (Sandbox Code Playgroud)

c c++ android native android-studio

2
推荐指数
1
解决办法
2322
查看次数