Android类上的字节码操作(Bytecode manipulation on Android class)
我想在android.view.View类(添加方法)上进行字节码操作,是否可能? 我应该使用javassist还是使用不同的库?
谢谢
I would like to do bytecode manipulation on android.view.View class (adding methods), is it possible? Should I use javassist or maybe a different library?
Thanks
原文:https://stackoverflow.com/questions/36728336
更新时间:2023-10-07 13:10
最满意答案
对于我需要的,这是我做的,基于@samplebias的评论上面:
import time millis = int(round(time.time() * 1000)) print millis
Quick'n'easy。 感谢所有,抱歉的大脑放屁。
为了重用:
import time current_milli_time = lambda: int(round(time.time() * 1000))
然后:
>>> current_milli_time() 1378761833768
For what I needed, here's what I did, based on @samplebias' comment above:
import time millis = int(round(time.time() * 1000)) print millis
Quick'n'easy. Thanks all, sorry for the brain fart.
For reuse:
import time current_milli_time = lambda: int(round(time.time() * 1000))
Then:
>>> current_milli_time() 1378761833768
相关问答
更多-
从毫秒获取时间对象(Get time object from milliseconds)[2023-07-12]
您可以直接从毫秒创建timedeltas: datetime.timedelta(milliseconds=2588832) You can create timedeltas directly from milliseconds: datetime.timedelta(milliseconds=2588832) -
在标准的C lua,no。 您将不得不安定几秒钟,除非您愿意自己修改lua解释器,以使os.time使用您想要的分辨率。 但是,如果您正在为其他人编写代码来自行运行,而不是像完全控制环境的Web应用程序那样,那可能是不可接受的。 编辑:另一个选择是在C中编写自己的小型DLL,它使用一个新功能来扩展lua,该函数将为您提供所需的值,并且要求将该代码分发给将要使用的代码。 In standard C lua, no. You will have to settle for seconds, unless you ...
-
您可以使用boost::posix_time::time_duration获取时间范围。 例如这样 boost::posix_time::time_duration diff = tick - now; diff.total_milliseconds(); 为了获得更高的分辨率,您可以更改您正在使用的时钟。 例如: boost::posix_time::microsec_clock ,尽管这可能取决于操作系统。 在Windows上,例如, boost::posix_time::microsecond_cl ...
-
对于我需要的,这是我做的,基于@samplebias的评论上面: import time millis = int(round(time.time() * 1000)) print millis Quick'n'easy。 感谢所有,抱歉的大脑放屁。 为了重用: import time current_milli_time = lambda: int(round(time.time() * 1000)) 然后: >>> current_milli_time() 1378761833768 For w ...
-
如果您有权访问C ++ 11库,请查看std::chrono库。 您可以使用它来获得Unix Epoch以来的毫秒数: #include
// ... using namespace std::chrono; milliseconds ms = duration_cast< milliseconds >( system_clock::now().time_since_epoch() ); If you have access to the C++ 11 libraries, ... -
我不相信有“毫秒时间”的日历字段,但您可以使用: long millisecondOfDay = TimeUnit.HOURS.toMillis(cal.get(Calendar.HOUR_OF_DAY)) + TimeUnit.MINUTES.toMillis(cal.get(Calendar.MINUTE)) + TimeUnit.SECONDS.toMillis(cal.get(Calendar.SECOND)) + cal.get(Calendar.MILLISEC ...
-
vala:这是以毫秒为单位获取当前时间的正确方法吗?(vala: is this the correct way to get the current time in milliseconds ?)[2023-07-05]
GLib.DateTime是一种有效的方法,当你请求本地时间然后将其转换为unix时间(隐式转换为UTC)时,有点奇怪。 但真正的问题是,你将毫秒(1/1000秒)和微秒(1/1000000秒)混为一谈。 所以把最后一行改为 var msec = (sec * 1000) + (now.get_microsecond () / 1000); 或者, 更简单的方法是使用GLib.get_real_time : int64 msec = GLib.get_real_time () / 1000; 根据您的使 ... -
能够使用以下方法获得所需的结果: import datetime currenttime = datetime.datetime.now() finaltime = currenttime + datetime.timedelta(milliseconds=milliseconds) print finaltime.strftime('%H:%M:%S.%f') Was abled to achieve desired result using: import datetime currenttime = ...
-
Sys.time() * 1000.0 - http://api.haxe.org/Sys.html#time time():Float给出最精确的时间戳值(以秒为单位) 为了清楚起见,我尝试了这一点,并获得了cpp目标的毫秒分辨率。 Sys包可用于cpp,cs,java,macro,neko,php和python。 Sys.time() * 1000.0 - http://api.haxe.org/Sys.html#time Gives the most precise timestamp value ( ...
-
在Unix上,使用gettimeofday()以微秒为单位获得答案并缩放到毫秒。 或者使用POSIX clock_gettime()以纳秒为单位获得答案并缩放到毫秒。 On Unix, use gettimeofday() to get the answer in microseconds and scale to milliseconds. Or use POSIX clock_gettime() to get the answer in nanoseconds and scale to millisec ...