首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android注解@Receiver

android注解@Receiver
EN

Stack Overflow用户
提问于 2014-11-12 16:22:08
回答 1查看 723关注 0票数 1

我正在尝试使用android注释库做广播接收器,有两种方法,但ide不能识别此代码中的@Receiver或@ReceiverAction

代码语言:javascript
复制
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.
    }
}

如果我尝试另一种方式,那么在活动中

代码语言:javascript
复制
  @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.
}

这就是我所看到的错误

EN

回答 1

Stack Overflow用户

发布于 2014-11-12 16:27:22

您需要导入正在使用的注释类。

例如,添加

代码语言:javascript
复制
import org.androidannotations.annotations.Receiver;
import org.androidannotations.annotations.ReceiverAction;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26882267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档