我在通过intent 获得传递兑现过的时候报错,空指针,我是getMap方法进行传值,代码如下
1
2
3
4
5
6
7
8
9
|
public void getMap(View view){
Intent i = new Intent( this , BreweryYourTopBeers. class );
Log.d( "map" , e.beerBreweryId);
i.putExtra( "breweryID" , e.beerBreweryId);
i.setClass( this , BreweryMap. class );
startActivity(i);
}
|
从我的日志中能够看到 在传值之前e.beerBreweryId 确实有值,我在下面的代码中获取改值
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
public class BreweryMap extends ActionbarMenu {
BeerData e;
String beerID;
GoogleMap map;
//从bundle 中获得beer 详细信息
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.activity_brewerymap);
//get brewery data
//get beer data
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String breweryID = extras.getString( "brewreyID" );
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
String url = "http://api.brewerydb.com/v2/brewery/" + breweryID + "?key=myKey&format=json&withLocations=y" ;
Log.d( "map" , url);
new myAsyncTask( this ,map).execute(url);
} } |
我每次获得值都是NULL ,不知道是什么原因.
处理方法
有一行写错误了.
把
String breweryID = extras.getString("brewreyID");
换成
String breweryID = extras.getString("breweryID");
原文地址:http://www.itmmd.com/201411/134.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。
相关推荐
android activityIntent 传值 传对象
Android Intent多种传值方式 https://blog.csdn.net/qq_31939617/article/details/80742103
本篇文章是对android中Intent传值与Bundle传值的区别进行了详细的分析介绍,需要的朋友参考下
文档+代码,android Application全局传值替代Intent传值,解决了Intent传值的限制
Activity生命周期及Intent传值
本代码为博客代码,博客地址:http://blog.csdn.net/zhangjinhuang
Intent跳转传值,和Activity返回传值
Xamarin.Android之Intent传递对象简单实例,实现的是IParcelable接口
实现Intent跳转及传值.用Intent方式建立两个Activity页面如下
该资源主要包含了Android中Intent中如何传值的几种方法: 1:基本数据类型,包含了Java八种基本数据类型和CharSequece文本 2:八种数据类新对应数组和CharSequece文本数组 3:Bundle传值 4:ArrayList集合 5:...
只有一个活动的应用也太简单了吧?没错,你的追求应该更高一点。不管你想创建多少 个活动,方法都和上一节中介绍的是一样的。...标只会进入到该应用的主活动,那么怎样才能由主活动跳转到其他活动呢?...
android页面跳转传值
支持动态增加的listview,同时支持intent传值,使用putextra将数值传递给另一个activity,另一activity通过hasextra补捉到获取的intent数值
我们可以通过Intent类中的putExtra方法可以将简单的数据类型和序列化对象保存到Intent对象中,然后在目标的Activity中使用getXxx方法取出对应的数据。
Activity之间使用intent(可以是Bundle)传值和回传值的demo
intent 两个activity 通过intent进行值得传递
主要为大家详细介绍了Android利用Intent启动和关闭Activity的相关操作,感兴趣的小伙伴们可以参考一下
自制的ListView数据单击后,Intent跳转到另一个界面,还运用到了ToggleButton Toast SimpleAdapter HashMap 互相学习,顺便赚点分数更加好好学习 祝大家一起成功
演示了android系统中页面跳转,页面间传值的方法。Intent的用法