错误意图获取数据 [英] error getting data with Intent

查看:202
本文介绍了错误意图获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个问题,我看不出有什么办法解决它(我已经试过所有)。
我做了Parcelable类来发送意图对象的数组。在第一个活动我送这个数组对象。在第二个活动我送一个整体,我在第三个活动回暖。
而事实证明,捕捉整时,它给我一个错误,并没有什么应用程序打开,你不明白关闭,因为我得到的错误是,没有这样做的第三个活动。如果我评论该线路拿起泰尔塞整个活动误会我的意思,我也通过使用对象数组非常清楚。但我也需要整个第二活动。
离开code,看看你的想法。

I was a problem and I see no way to fix it (I've tried them all). I did the Parcelable class to send an array of objects with intent. In the first activity I send this array of objects. In the second activity I send a whole, and I pick up in the third activity. And it turns out, it gives me an error when capturing the whole, and nothing Application open, you do not understand closes, since the error I get is the third activity that fails to do so. If I comment the line to pick up the entire activity in terce not get me wrong, and I also pass the array with objects perfectly well. But I also need the whole of the second activity. Leave the code to see what you think.

发送作业的阵列。第一次活动

Sending the array of ob. first Activity

>  //creamos el intent y le pasamos la clase a mostrar
            Intent i = new Intent(this, MainActivity.class);
            Bundle contenedor= new Bundle();

            //le cargamos al bundle un objeto parceable que se almacenara
            //bajo la key "array" y contendrá nuestra lista
            contenedor.putParcelable("array",lista_musica);
            //cargamos el intent con el bundle
            i.putExtras(contenedor);
            //lanzamos el intent
            startActivity(i);

发送整个次活动

意图II =新意图(Generos.this,MainActivity.class);

Intent ii=new Intent(Generos.this,MainActivity.class);

ii.putExtra(sentGeneroId,generoId);

ii.putExtra("sentGeneroId", generoId);

startActivity(ⅱ);

startActivity(ii);

从第三个活动收集的数据

Collect data from the Third Activity

Bundle b = getIntent().getExtras();
if (b != null) {

lista_musica = b.getParcelable(阵列);
generoId =(整数)b.get(sentGeneroId);
}

Log.i("mi error","el generoID: "+generoId);

Log.i("mi error","el ARRAY del main: "+lista_musica);

该Parcelable类没有想到这个错误,正如我所说previously提到的行

The Parcelable class not think this wrong, as I said previously mentioned line

generoId =(整数)b.get(sentGeneroId);

generoId = (Integer) b.get ("sentGeneroId");

不给我的错误,正确地向我发送对象的数组。我用尽了一切。我设法不要离开我的错误注释掉该行,但在第三个活动数组总是空的,但不再符合或我做什么.............
你看,如果有人与更多的视力,我知道失败。
谢谢你。

does not give me error and sends me correctly the array of objects. I've tried everything. I managed not to leave me the error uncommented that line, but the array in the third activity was always null, but no longer or what I did ............. You see if someone with more sight I know that fails. Thank you.

推荐答案

试试这个办法,希望这将帮助你解决你的问题。

在您的SecondActivity传递generoId为字符串出方的让您直接从意图而不是意图捆绑获取此值

In your SecondActivity you pass generoId as String out side Bundle so you get this value directly from Intent instead of Intent Bundle.

generoId = Integer.parseInt(getIntent().getStringExtra("sentGeneroId"));

这篇关于错误意图获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆