The method setClass(Context, Class?) in the type Intent is not applicable for the arguments (GameV
在当前短信内容的activity中写
Bundle bun = new Bundle();
bun.putString("message", "短信内容");
Intent in = new Intent(第二个Activity.this, 第一个Activity.class);
in.putExtras(bun);
在要传内容的activity中写:
Bundle bu = this.getIntent().getExtras();
String message = bu.getString("message");//获取短信内容
public class SMSReceiver extends BroadcastReceiver
{
/*当收到短信时,就会触发此方法*/
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++)
{
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
//调用显示短信内容的Activity
Intent intent = new Intent();
intent.setClass(this, MyView.class);
intent.putExtra("sms_body", smsMessage[0].getMessageBody());
startActivity(intent);
}
}
回复三楼,按您所说的改了,
//调用显示短信内容的Activity
Intent intent2 = new Intent();
intent2.setClass(this, Activity01.class);
//setClass出错:The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (SMSReceiver, Class<Activity01>)
intent2.putExtra("sms_body", smsMessage[0].getMessageBody());
startActivity(intent2);
//startActivity出错:The method startActivity(Intent) is undefined for the type SMSReceiver
回复二楼: 二楼思路明确;
回复楼主: 有没有注意到二楼跟三楼的代码区别——intent.setClass(第二个Activity.this, 第一个Activity.class)和intent.setClass(this, 第一个Activity.class),当在方法中调用setClass()这个方法的时候,是可以用this的。挡在内部类中(比如事件监听类OnClickListener)调用这个方法的时候要变为Activity.class。希望能够帮助楼主。
The method setClass(Context, Class?) in the type Intent is not applicable for the arguments (GameV相关推荐
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable
开始学习 android 了,学习的是高明鑫老师的android视频教程(android视频教学). 学到第八讲时, 在写动态设置时报错: The method setOnClickListener( ...
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the argu
eclipse 写 android 自动添加事件,报错 The method setOnClickListener(View.OnClickListener) in the type View is ...
- The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the argument
Fragment 的使用过程中总是遇到各种各种奇怪的报错, 例如这样的 错的根本原始吗就是包导入错了,也不算导入错了,就是导入的包匹配 这个不匹配就是你的activity中导入的包和几个fragmen ...
- MapReduce操作时Error:The method setInputPaths(JobConf, String) in the type FileInputFormat is not
问题描述 今天在写java API的MapReduce操作时,出现了Error:The method setInputPaths(JobConf, String) in the type FileIn ...
- The method getTextContent() is undefined for the type Node 错误解决办法
在开发项目中,出现一个错误:The method getTextContent() is undefined for the type Node,解决办法: 网上查大部分是说jdk版本问题,发现不是, ...
- tomcat 报错 Status 500 - Mapper method ‘xxxxx‘ has an unsupported return type: class xxx
myBatis 接口写了 insert ,对应的dao层里写的返回值是一个实体类 User add(User user); 报错 Status 500 - Mapper method 'xxxxx' ...
- Mapper method 'comxx' has an unsupported return type
报错场景: 在学习SpringBoot与mybatis整合的时候,对数据库的数据进行更新操作,sql执行成功,但是返回了如下的异常 org.apache.ibatis.binding.BindingE ...
- 执行时遇到 For apos;context.set_contextapos;, package type xxx support apos;devic
[技术干货-功能调试] 执行时遇到 For 'context.set_context', package type xxx support 'device_target' type xxx, but ...
- java报错The method get_discount() is undefined for the type该如何处理?
1.例子如下图所示: 2. 增加代码 private static double get_discount() { // TODO Auto-generated method stub ...
最新文章
- 我也来说一下SilverLight3的ChildWindow--带Logo的标题
- java替换特殊字符串
- vm无法删除干净老版本,新版本无法安装解决
- python弹出警告框_selenium+webdriver+python 中警告框的处理方法
- JavaScript中的作用域、作用域链、预解析
- 洛谷T44252 线索_分治线段树_思维题
- 【图像处理】——Python霍夫变换之直线检测(主要是两个函数HoughlinesHoughlinesP)
- 失业日志:2009年10月12日星期一
- gispython定义查询_定义查询方法
- [原创]Tsys 2.0 beta 官方版无法使用自定义SQ
- Hive基础调优详解
- python期货自动交易_3自动交易模块_python量化交易_Python视频-51CTO学院
- c/c++:双人对战五子棋源代码
- 在vue项目中使用supermap,基于 SuperMap iClient 8C(2017) for JavaScript,底图为天地图
- bmi计算 python_Python中的BMI计算器
- 恋词题源报刊Unit5背诵
- 繁华落幕,空余一地苍凉
- 【str家族】如何使用处理字符和字符串的库函数
- c# 备份oracle waitforexit()方法死锁,从过程的空的stdout原因同步读数据死锁[重复](Synchronized reading dat...
- CASS3D2.0.3旗靓版又双叕更新了,赶快使用新版本的吧(下载地址在文尾)
热门文章
- PJzhang:互联网是有国界
- 【转载】从头编写 asp.net core 2.0 web api 基础框架 (1)
- 省队集训Day3 tree
- Android判断一个Service是否运行
- Ruby: 延迟计算与优化
- java 自定义一个容器类
- BZOJ3123: [Sdoi2013]森林
- Hardcoded string 下一步, should use @string resource警告 (转载)
- Windows Installer (MSI) 详解 参数介绍
- windows下安装RabbitMQ消息服务器 + 读写队列