2011-10-17 33 views
1

在我的Android應用程序中,我想在活動之間傳輸數據;提到了FirstActivity.class和SecondActivity.class。但在我的FirstActivity中顯示的是NullPointerException。你能告訴我我班有什麼問題嗎?Android Bundle NullPointer

FirstActivity.class:

Bundle bundle = getIntent().getExtras(); 
     fingerPrintID = bundle.getString("ThumbInfo"); 

SecondActivity.class:

Bundle bundle = new Bundle(); 
bundle.putString("ThumbInfo", FingerImageData.toString()); 
Intent enroll=new Intent(First.this,Enroll.class); 
enroll.putExtras(bundle); 
startActivity(enroll); 
+1

11個問題,沒有被接受的答案? – slayton

回答

1

假設,,,如果從活性1的數據傳遞到活性2 ::

在活動1 ::

  Intent intent = new Intent(activity1.this, activity2.class); 
      intent.putExtra("ThumbInfo", thumbInfo); 
      startActivity(intent); 

在活動2::(在onCreate方法)

  Bundle bundle = getIntent().getExtras(); 
      String category_name = bundle.getString("ThumbInfo"); 
0

使用

enroll.putExtras(bundle); 

你必須通過捆綁的意圖。