我正在尝试使用两种方式使用android注释库进行广播接收器,但是ide无法像此代码那样识别@Receiver或@ReceiverAction
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.androidannotations.annotations.EReceiver;
/**
* Created by M.Hemdan on 11/12/2014.
*/
@EReceiver
public class MyBroadCast extends BroadcastReceiver {
@ReceiverAction(actions = android.content.Intent.VIEW, dataSchemes = "http")
protected void onHttp() {
// Will be called when an App wants to open a http website but not for https.
}
@ReceiverAction(actions = android.content.Intent.VIEW, dataSchemes = {"http", "https"})
protected void onHttps() {
// Will be called when an App wants to open a http or https website.
}
}
然后在活动中,如果我尝试其他方式
@Receiver(actions = android.content.Intent.VIEW, dataSchemes = "http")
protected void onHttp() {
// Will be called when an App wants to open a http website but not for https.
}
@Receiver(actions = android.content.Intent.VIEW, dataSchemes = {"http", "https"})
protected void onHttps() {
// Will be called when an App wants to open a http or https website.
}
这是我看来的错误
最佳答案
您需要导入正在使用的注释类。
例如,添加
import org.androidannotations.annotations.Receiver;
import org.androidannotations.annotations.ReceiverAction;
关于java - android注解@Receiver,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26882267/