目前,我正在使用SmsManager
从安卓系统发送一条文本消息,它工作正常。
但是我确实想听到意图的结果,并在此基础上采取一些行动,下面的代码应该可以工作,但我在运行时得到的getResultCode
是未定义的(但它在调试控制台上可以工作)
app.android.registerBroadcastReceiver(this.id, () => {
if(this.getResultCode() == android.app.Activity.RESULT_OK){
// Sucess
} else {
// Failure
}
});
如何正确地从getResultCode
方法中获取值?
发布于 2018-10-18 07:58:54
我使用的是箭头函数,因此得到了错误的上下文。
将箭头函数更改为标准函数修复了此问题
app.android.registerBroadcastReceiver(this.id, function(){
if(this.getResultCode() == android.app.Activity.RESULT_OK){
// Sucess
} else {
// Failure
}
});
https://stackoverflow.com/questions/52547933
复制相似问题