我从数据库中得到了一些数据。无需将数据传递给 ShowData 活动即可完成所有操作。
bDBget.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
db.open();
String data = db.getThat();
db.close();
Intent i = new Intent(getApplicationContext(), ShowData.class);
i.putExtra("data", data);
startActivity(i);
}
});
androidManifest 没有问题。问题可能是什么?
日志猫
10-12 17:05:35.248: D/gralloc_goldfish(1622): Emulator without GPU emulation detected.
10-12 17:05:46.658: I/Choreographer(1622): Skipped 33 frames! The application may be doing too much work on its main thread.
10-12 17:05:48.549: D/AndroidRuntime(1622): Shutting down VM
10-12 17:05:48.568: W/dalvikvm(1622): threadid=1: thread exiting with uncaught exception (group=0x41465700)
10-12 17:05:49.298: D/dalvikvm(1622): GC_FOR_ALLOC freed 159K, 9% free 2858K/3136K, paused 236ms, total 297ms
10-12 17:05:49.298: E/AndroidRuntime(1622): FATAL EXCEPTION: main
10-12 17:05:49.298: E/AndroidRuntime(1622): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.channel/com.example.channel.ShowData}: java.lang.NullPointerException
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.os.Looper.loop(Looper.java:137)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-12 17:05:49.298: E/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 17:05:49.298: E/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:525)
10-12 17:05:49.298: E/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-12 17:05:49.298: E/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-12 17:05:49.298: E/AndroidRuntime(1622): at dalvik.system.NativeStart.main(Native Method)
10-12 17:05:49.298: E/AndroidRuntime(1622): Caused by: java.lang.NullPointerException
10-12 17:05:49.298: E/AndroidRuntime(1622): at com.example.channel.ShowData.onCreate(ShowData.java:21)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.Activity.performCreate(Activity.java:5133)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-12 17:05:49.298: E/AndroidRuntime(1622): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
10-12 17:05:49.298: E/AndroidRuntime(1622): ... 11 more
ShowData 活动在这里。
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.show);
tvGeneral = (TextView) findViewById(R.layout.show);
Bundle extras = getIntent().getExtras();
String data = extras.getString("data");
tvGeneral.setText(data);
}
我现在真的无法理解 logcat 的任何内容。