在活动之间传递int数组

时间:2015-11-11 21:19:14

标签: java android arrays android-intent

我正在尝试使用Intent将int数组传递给下一个活动。 这是代码。 发送

Intent mIntent=new Intent(getApplicationContext(),activityvogel.class);
mIntent.putExtra("stock",stock);
startActivity(mIntent);}

获取

Bundle extras = getIntent().getExtras();
        int stock [] = extras.getIntArray("stock");

但我总是得到numberformatexception 这是我的logcat

  

15015-15015 / com.example.pantelis.ptyxiakh E / AndroidRuntime:FATAL   例外:主要       过程:com.example.pantelis.ptyxiakh,PID:15015       java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.pantelis.ptyxiakh / com.example.pantelis.ptyxiakh.activityvogel}:   java.lang.NumberFormatException:无效的int:“null”               在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)               在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)               在android.app.ActivityThread.access $ 800(ActivityThread.java:156)               在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1351)               在android.os.Handler.dispatchMessage(Handler.java:102)               在android.os.Looper.loop(Looper.java:211)               在android.app.ActivityThread.main(ActivityThread.java:5389)               at java.lang.reflect.Method.invoke(Native Method)               在java.lang.reflect.Method.invoke(Method.java:372)               在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1020)               在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)        引起:java.lang.NumberFormatException:无效的int:“null”               在java.lang.Integer.invalidInt(Integer.java:138)               在java.lang.Integer.parseInt(Integer.java:358)               在java.lang.Integer.parseInt(Integer.java:334)               在com.example.pantelis.ptyxiakh.NextActivity.onCreate(NextActivity.java:41)               在com.example.pantelis.ptyxiakh.activityvogel.onCreate(activityvogel.java:19)               在android.app.Activity.performCreate(Activity.java:5990)               在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)               在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)   在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)   在android.app.ActivityThread.access $ 800(ActivityThread.java:156)   在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1351)   在android.os.Handler.dispatchMessage(Handler.java:102)   在android.os.Looper.loop(Looper.java:211)   在android.app.ActivityThread.main(ActivityThread.java:5389)   at java.lang.reflect.Method.invoke(Native Method)   在java.lang.reflect.Method.invoke(Method.java:372)   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1020)   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)

如果有人能提供帮助,我将不胜感激

0 个答案:

没有答案