首页 \ 问答 \ 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)

无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)

我正在编写一个AIR Native Extension,它必须在新的Android Thread上做一些工作。 我必须使用Context来获取此Thread中的设备信息。 我在一个新的线程中调用FREContext的getActivity方法,即segfaults。

在我的FREContext扩展类中,我有:

public class MyExtensionContext extends FREContext {    
    public void doThreadWork() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                // calling com.adobe.fre.FREContext.getActivity(), crashes here
                Activity act = getActivity(); 
            }
        }
    }
}

根据Adobe文档,不允许在正在运行的FREFunction线程之外访问FREObjects。 FREContext和新线程是否有类似的情况?


I'm writing an AIR Native Extension that has to do some work on a new Android Thread. I have to use a Context to get device information in this Thread. I am calling the getActivity method of FREContext in a new thread, which segfaults.

In my FREContext-extended class, I have:

public class MyExtensionContext extends FREContext {    
    public void doThreadWork() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                // calling com.adobe.fre.FREContext.getActivity(), crashes here
                Activity act = getActivity(); 
            }
        }
    }
}

According to the Adobe documentation, FREObjects are not allowed to be accessed outside the FREFunction thread that's running. Is there a similar case with FREContext and new threads?


原文:https://stackoverflow.com/questions/22797274
更新时间:2024-05-05 20:05

相关问答

更多
  • 要以简单的方式实现延迟加载控制器,您必须执行以下操作: 保存$controllerProvider.register (这是将控制器添加到已启动的AngularJS应用程序中的唯一方法)到应用程序( main.js )中的变量: var app = angular.module('app',["ngRoute"]); app.config(['$routeProvider', '$controllerProvider', function($routeProvider, $controllerPro ...
  • @yonexbat,谢谢你是对的。 如果使用.... const response = this.http.put(url, data, { responseType: 'text'}).toPromise(); ... 问题已经解决了。 @yonexbat, Thanks you are right. If using .... const response = this.http.put(url, data, { responseType: 'text'}).toPromise(); ... the ...
  • 工厂/服务是您正在寻找的。 Ajax调用应该在工厂方法中进行,然后工厂方法将数据返回给控制器(在您的示例中为myCtrl)。 您应该将控制器(myCtrl)与路由提供程序本身中的视图(Activity)绑定。 这是一个可以为您提供清晰图片的示例。 工厂如何运作 Factory/Service is what you are looking for. Ajax call should be made inside a factory method which in turn returns the data ...
  • 我通过使用XHRBackend和mockBackend而不是我的Http Stub来解决问题。 it('Should show a list of 10 feed', inject([XHRBackend], (mockBackend) => { mockBackend.connections.subscribe((connection) => { connection.mockRespond(new Response(new ResponseOptions({ ...
  • 使用$ http服务上传文件时,设置Content-Type: undefined很重要。 var config = { headers: { "Content-Type": undefined, } }; var promise = $http.put(url, file, config); $ http服务的默认内容类型是application/json 。 通过设置Content-Typ ...
  • 您可以使用$scope变量来检测ajax请求的进度。 基于该变量,您可以显示或隐藏微调器 $scope.sendAjax = function() { $scope.prograssing = true; // show spinner $http.get('data.json').then(function() { //sucess $scope.prograssing = false; // hide spinne ...
  • 在查询中,对于$ .param来说,angular具有类似的功能。 下面的代码制定了发布。 $scope.showslot = function(slotid){ $scope.show(); //data: $.param({slotid: slotid}) var pdata = { slotid : slotid , docid : $scope.docid}; $http({ method: 'POST', ...
  • 我一眼就能看到的唯一情况是你有一个配置块被添加到$ stateProvider状态的末尾。 我不相信$ stateProvider API上有一个实际的配置函数。 将$ urlRouterProvider注入合并到主配置块中并添加$ urlRouterProvider.otherwise(“/ home”); 可能会在$ stateProvider.state(...)调用之后调用该配置块中的某处。 我希望这能够帮到你。 The only thing I see at a glance is that yo ...
  • 随着RC.6发布, angular2团队宣布了包装配置的新突破性变化 https://github.com/angular/angular/blob/master/CHANGELOG.md#breaking-changes-1 npm包:ESM(ES6模块)格式的代码现在发布在npm包中的默认位置,其中package.json的主条目指向UMD包(主要用于节点和webpack 1用户)。 如果您使用SystemJS加载Angular,则应调整SystemJS配置以指向UMD包(存在于npm包中)。 请参阅此 ...
  • 您需要从HTML条目文件中的node_modules / angular2 / bundles文件夹导入http.dev.js: You need to import the http.dev.js from the node_modules/angular2/bundles folder in your HTML entry file: