超级骨干(Super in Backbone)
当我覆盖
Backbone.Model
的clone()
方法时,有没有办法从我的植入中调用这个覆盖方法? 这样的东西var MyModel = Backbone.Model.extend({ clone: function(){ super.clone();//calling the original clone method } })
When I override the
clone()
method of aBackbone.Model
, is there a way to call this overriden method from my implantation? Something like this:var MyModel = Backbone.Model.extend({ clone: function(){ super.clone();//calling the original clone method } })
原文:https://stackoverflow.com/questions/8596861
更新时间:2023-07-16 21:07
最满意答案
Try calling record.start() instead of .run().
From the Java API Docs:
start() Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
You also may want to look into AsyncTask.
相关问答
更多-
android线程和处理程序 - 从后台线程更改UI对象(android threading and handler - Changing UI objects from a background thread)[2021-12-05]
您基本上只需添加一个并发送Message或Runnable 。 private final Handler mUiThreadHandler = new Handler(Looper.getMainLooper()); void fromAnyThread() { final String importantDataFromBackGroundThread = "!!!"; mUiThreadHandler.post(new Runnable() { @Override ... -
尝试调用record.start()而不是.run()。 从Java API文档 : start()使该线程开始执行; Java虚拟机会调用此线程的运行方法。 你也可能想看看AsyncTask 。 Try calling record.start() instead of .run(). From the Java API Docs: start() Causes this thread to begin execution; the Java Virtual Machine calls the run m ...
-
Android后台线程如何为新活动提供数据?(How can Android background thread provide data to new activities?)[2022-07-13]
如果您的活动位于相同的软件包/应用程序中,则可以将该线程的引用放入Application对象中,以便可以从您的所有活动中访问它。 您需要创建一个自定义应用程序子类并在清单中引用它。 如果您正在查看来自不同包的活动,我可以使用广播接收器模型或绑定服务。 If your activities are in the same package/app, you could put a reference to the thread in the Application object so that it can b ... -
避免你所描述的情况的唯一可靠方法是将结果保存到某种存储中。 您可以启动服务来执行长时间运行的任务,并将结果写入数据库,并在完成时发送本地广播。 如果活动恰好位于前台,它将接收广播并更新其状态以了解该过程已完成,并可从您使用的任何持久存储机制中删除有关该任务的信息。 如果活动在后台,则服务将完成,发送广播并保留结果。 下次活动到达前台时,它应检查此持久存储并查看是否存在未解析的任务状态,并更新其状态以进行匹配。 因此,一个示例纲要可能是(让我们使用“上传照片”作为任务): 用户单击按钮以开始上载图像 Acti ...
-
在调用list.add()之前,请确保已实例化列表对象: list = new ArrayList
(); Make sure you have instantiated your list object before you call list.add(): list = new ArrayList (); -
Android线程(Android Threading)[2022-03-26]
上面的代码没有任何问题会导致ANR ,因此很可能发生以下情况之一: 您正在尝试从doInBackground修改用户界面(UI) doInBackground发生异常 如果在收到错误时发布LogCat输出或堆栈跟踪,则更容易识别。 There aren't any problems with the code above that would cause an ANR, so most likely one of the following is happening: You are trying to m ... -
AsyncTask自动为你创建一个新的线程,所以你在doInBackground()做的所有事情都在另一个线程上。 你在做什么是这样的: AsyncTask创建一个新的线程并运行doInBackground() 。 从AsyncTask-Thread创建一个新的Thread( t )。 doInBackground()完成,因为它所做的就是创建Thread t并跳转到onPostExecute() 。 线程t仍然会在后台运行(但是,您不要在t上调用start() ,这意味着它不会启动)。 相反,你希望你的d ...
-
Android背景线程(Android background threading)[2021-11-23]
IntentService IntentService绝对是一种有效的方法。 您可以使用广播将结果返回到应用程序的另一个组件,无论是活动还是其他服务,例如: 启动IntentService - 如果需要某些参数,请将它们放在服务意图的Extras中。 您的IntentService在后台线程上运行,直到计算完成。 完成后,发送一个广播,计算结果放在意图附加内容中。 在您的活动中,注册一个BroadcastReceiver ,它将监听您的计算结果广播。 在您的Activity中获取广播后,从intent ex ... -
当设备空闲时,CPU将停止并且所有正在运行的线程都会暂停(C ++或Java)。 如果它因任何原因被唤醒,你的C ++线程将再次开始工作,因此随机行为:其他应用程序或服务可能会不时唤醒设备。 添加部分唤醒锁可以在您的情况下工作,但这将防止CPU空闲,这将导致一些电池耗尽。 如果你不在乎你可以使用这种方法,如果电池就绪是一个问题, 你可以使用Java报警API定期唤醒设备。 然后java API可以通过JNI调用C ++代码 。 重复警报的Android文档: https : //developer.andr ...
-
在android中痛苦的线程(Painful threading in android)[2021-10-22]
doinBackground是非UI线程,所以永远不要更新此方法中的任何UI(View)... 并使用OnPostExecute or OnProgressUpdate for update UI @Override protected Void doInBackground(Void... params) { //here just background task , //its non UI Thread so dont set ant view her ...