私の主な活動:
count=count+1;
//the problem seems to be in this line of code below
String fileName=f.getFileName(count).toString();
// the method below invokes a method from another class. it works fine so please ignore
helloTxt.setText(readText.readTxt(fileName));
fは、ファイル名を取得するFileNameクラスのオブジェクトです。
public class FileName {
String file;
public String getFileName(int count) {
// TODO Auto-generated method stub
if (count==1)
{
file.equals("textone");
}
if(count==2)
{
file.equals("texttwo");
}
return file;
}
}
ログ猫:
03-19 12:02:00.554: D/AndroidRuntime(5550): Shutting down VM
03-19 12:02:00.554: W/dalvikvm(5550): threadid=1: thread exiting with uncaught exception (group=0x418342a0)
03-19 12:02:00.562: E/AndroidRuntime(5550): FATAL EXCEPTION: main
03-19 12:02:00.562: E/AndroidRuntime(5550): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testflashfile/com.example.testflashfile.MainActivity}: java.lang.NullPointerException
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.os.Looper.loop(Looper.java:137)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.ActivityThread.main(ActivityThread.java:4895)
03-19 12:02:00.562: E/AndroidRuntime(5550): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 12:02:00.562: E/AndroidRuntime(5550): at java.lang.reflect.Method.invoke(Method.java:511)
03-19 12:02:00.562: E/AndroidRuntime(5550): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
03-19 12:02:00.562: E/AndroidRuntime(5550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
03-19 12:02:00.562: E/AndroidRuntime(5550): at dalvik.system.NativeStart.main(Native Method)
03-19 12:02:00.562: E/AndroidRuntime(5550): Caused by: java.lang.NullPointerException
03-19 12:02:00.562: E/AndroidRuntime(5550): at com.example.testflashfile.FileName.getFileName(FileName.java:11)
03-19 12:02:00.562: E/AndroidRuntime(5550): at com.example.testflashfile.MainActivity.onCreate(MainActivity.java:48)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.Activity.performCreate(Activity.java:5163)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-19 12:02:00.562: E/AndroidRuntime(5550): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
03-19 12:02:00.562: E/AndroidRuntime(5550): ... 11 more
03-19 12:02:11.164: I/Process(5550): Sending signal. PID: 5550 SIG: 9
すべてのアクティビティはマニフェストにリストされています。したがって、この問題を解決するための助けをいただければ幸いです。
前もって感謝します。