我正在尝试使用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.
}这就是我所看到的错误

发布于 2014-11-12 16:27:22
您需要导入正在使用的注释类。
例如,添加
import org.androidannotations.annotations.Receiver;
import org.androidannotations.annotations.ReceiverAction;https://stackoverflow.com/questions/26882267
复制相似问题