从 Activity B 的 Fragment B 中点击 “按钮” 跳转到 MainActivity 的 Fragment A
来源:互联网 发布:财务报表软件免费版 编辑:程序博客网 时间:2024/05/22 10:35
Fragment B 中使用的
MainActivity 中使用的
这样写在定制的安卓系统中能实现,但是在原生安卓或者改动不大的安卓系统中就报错,如下:
java.lang.IllegalStateException: API cannot be called whiile activity is paused
at android.nfc NfcAdapter.enforceResumed (NfcAdapter)
at android.nfc.NfcAdapter.enableForegroundNdefPush
at com.项目名称.ui.MainActivity.sendNfcCode
at com.项目名称.ui.MainActivity.setCurPoint
at com.项目名称.ui.MainActivity.onNewIntent
at adnroid.app.Instrumentation .callActivityOnNewIntent
希望懂的大大不吝教育,谢谢!
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_stroll:// 随便逛逛
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.putExtra("mk", "1");// 发送标志,使之能跳到首页
getActivity().startActivity(intent);
break;
}
}
MainActivity 中使用的
// 接收"随便逛逛"传过来的值显示首页
Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
mar = intent.getStringExtra("mk");
if (mar != null ) {
setCurPoint(0);// 显示Fragment A页面
}
}
这样写在定制的安卓系统中能实现,但是在原生安卓或者改动不大的安卓系统中就报错,如下:
java.lang.IllegalStateException: API cannot be called whiile activity is paused
at android.nfc NfcAdapter.enforceResumed (NfcAdapter)
at android.nfc.NfcAdapter.enableForegroundNdefPush
at com.项目名称.ui.MainActivity.sendNfcCode
at com.项目名称.ui.MainActivity.setCurPoint
at com.项目名称.ui.MainActivity.onNewIntent
at adnroid.app.Instrumentation .callActivityOnNewIntent
希望懂的大大不吝教育,谢谢!
0 0
- 从 Activity B 的 Fragment B 中点击 “按钮” 跳转到 MainActivity 的 Fragment A
- 从activity(A)跳转到其他activity(B)下面的fragment
- fragment A里面点击button跳转到fragment B的实现
- android中在fragment A里面点击button跳转到fragment B怎么实现?
- Activity 跳转到Fragment中(MainActivity中的Fragment)
- fragmentTabHost中点击一个fragment中的按钮,跳转到另外一个fragment的解决办法
- fragmentTabHost中点击一个fragment中的按钮,跳转到另外一个fragment的解决办法
- activity中跳转到fragment的思路
- Fragment中的Activity跳转到MainActivity中的其他Fragment方法
- Fragment互相切换,点击Fragment上的按钮跳转到Fragment简单总结
- Android从Fragment中跳转到Activity
- 从一个activity跳转到一个已存在activity的指定fragment中
- 关于从activity跳转到fragment里面的问题
- Activity A 跳转到 Activity B,生命周期的执行过程
- 从fragment跳转到activity,再返回到指定的fragment页面
- Android的fragment页面点击按钮切换到下一个fragment页面,由主activity控制
- 从一个Activity直接跳转到一个Fragment中,进行相应的操作
- Activity跳转到Fragment的问题
- 如何获取textarea标签里面的文本 在线等回复
- fragment实现底部标签 如何使底部标签一直存在
- iOS-简单的二级联动菜单
- android 开发中的一个问题,不知道怎么写标题,大神们进来看看吧!
- ToolBar使用详解+ToolBar按钮颜色修正方法
- 从 Activity B 的 Fragment B 中点击 “按钮” 跳转到 MainActivity 的 Fragment A
- ios 中NSData 拼接成功,但写入本地种只有前面的data
- android通知
- motan学习笔记 五 opentracing学习入门
- 【笔记】OpenSSL for Windows 编译
- android端和pc端使用usb进行socket通信,其中android是服务器端,pc是客户端。如何实现安卓端输入的数据通过按钮发送到pc端?
- 可以显示超大,长图片的ImageView
- GridLayout,子控件EditText内容超出屏幕
- 请教一个MVC问题