インテントを介して別のアクティビティからアクティビティを呼び出し、バンドル (文字列値) を介して値を渡していますが、アクティビティを開始できませんでした。これはコードであり、猫のエラーをログに記録してください。
別のアクティビティを呼び出しているアクティビティ
if(v==btndate){
Intent i2=new Intent(accounts.this,calcok.class);
String frm=edtdate1.getText().toString();
String to=edtdate2.getText().toString();
Log.e("acc->calcok","inbetween intents");
Log.e("from date",frm);
Log.e("to date",to);
i2.putExtra("from",(String)frm);
i2.putExtra("to",(String) to);
startActivity(i2);
}
前のアクティビティから呼び出されたアクティビティ
package dlp.android.digichronicle;
import java.io.IOException;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class calcok extends Activity{
DBHandandler myDbHelper=new DBHandandler(this);
SQLiteDatabase Mydatabase;
float inc,exp;
String s1,s2,s3;
String stattionlist,DBname="widgets";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.myDbHelper = new DBHandandler(this);
Bundle b=getIntent().getExtras();
System.out.println("Got from acc"+b);
String frm=b.getString("frm");
String to=b.getString("to");
if(b!=null)
{
Log.e("frm",frm);
Log.e("to",to);
Log.e("Entered accounts->" +"CALCCCC","");
try {
FetchingData();
myDbHelper.openDataBase();
Mydatabase = myDbHelper.getWritableDatabase();
String s =second.ge;
if(s.equalsIgnoreCase("accounts")){
ArrayList<Float> inclist=new ArrayList<Float>();
ArrayList<Float> explist=new ArrayList<Float>();
try{
explist =myDbHelper.calc(Mydatabase,"exp",frm,to);
inclist =myDbHelper.calc1(Mydatabase,frm,to);
}
catch(Exception e){
inclist.add(500.0f);
explist.add(320.0f);
}
float inc= sum(inclist);
float exp= sum(explist);
float sav=inc-exp;
if(sav<0){
s3="Deficit Amount";
}
else
{
s3=Float.toString(sav);
}
s1=Float.toString(inc);
s2=Float.toString(exp);
}
Toast.makeText(getApplicationContext(), "GOt Details",Toast.LENGTH_LONG).show();
} catch (SQLException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
myDbHelper.close();
Mydatabase.close();
Intent i3=new Intent(calcok.this,accounts.class);
i3.putExtra("inc",s1);
i3.putExtra("exp",s2);
i3.putExtra("sav",s3);
startActivity(i3);
}
}
public static float sum(ArrayList<Float> list){
if(list==null || list.size()<1)
return 0;
float sum = 0;
for(Float i: list)
sum = sum+i;
return sum;
}
private void FetchingData() {
try { myDbHelper.onCreateDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
Mydatabase = myDbHelper.getWritableDatabase();
}catch(SQLException sqle){
throw sqle;
}
}
}
Logcat エラー
11-24 20:52:26.318: I/System.out(842): cursortrue
11-24 20:52:29.267: D/Testing(842): Checkpoint 2
11-24 20:52:29.647: D/dalvikvm(842): GC_FOR_ALLOC freed 9093K, 24% free 30100K/39303K, paused 91ms
11-24 20:52:29.817: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:29.837: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:32.247: D/dalvikvm(842): GC_CONCURRENT freed 655K, 21% free 31399K/39303K, paused 5ms+23ms
11-24 20:52:32.337: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:32.366: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:32.767: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:32.797: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:35.757: E/acc->calcok(842): inbetween intents
11-24 20:52:35.847: I/System.out(842): Got from accBundle[mParcelledData.dataSize=64]
11-24 20:52:35.847: D/AndroidRuntime(842): Shutting down VM
11-24 20:52:35.858: W/dalvikvm(842): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
11-24 20:52:35.897: E/AndroidRuntime(842): FATAL EXCEPTION: main
11-24 20:52:35.897: E/AndroidRuntime(842): java.lang.RuntimeException: Unable to start activity ComponentInfo{dlp.android.digichronicle/dlp.android.digichronicle.calcok}: java.lang.NullPointerException: println needs a message
11-24 20:52:35.897: E/AndroidRuntime(842): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-24 20:52:35.897: E/AndroidRuntime(842): at and roid.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.os.Looper.loop(Looper.java:137)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-24 20:52:35.897: E/AndroidRuntime(842): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 20:52:35.897: E/AndroidRuntime(842): at java.lang.reflect.Method.invoke(Method.java:511)
11-24 20:52:35.897: E/AndroidRuntime(842): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-24 20:52:35.897: E/AndroidRuntime(842): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-24 20:52:35.897: E/AndroidRuntime(842): at dalvik.system.NativeStart.main(Native Method)
11-24 20:52:35.897: E/AndroidRuntime(842): Caused by: java.lang.NullPointerException: println needs a message
11-24 20:52:35.897: E/AndroidRuntime(842): at android.util.Log.println_native(Native Method)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.util.Log.e(Log.java:231)
11-24 20:52:35.897: E/AndroidRuntime(842): at dlp.android.digichronicle.calcok.onCreate(calcok.java:30)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.app.Activity.performCreate(Activity.java:4465)
11-24 20:52:35.897: E/AndroidRuntime(842): at an droid.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-24 20:52:35.897: E/AndroidRuntime(842): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-24 20:52:35.897: E/AndroidRuntime(842): ... 11 more
11-24 20:52:36.297: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:36.317: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:36.567: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:36.576: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:37.117: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:37.137: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:37.619: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:37.647: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:38.147: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:38.177: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:38.697: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:38.707: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:39.217: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:39.237: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:39.737: I/dalvikvm(842): threadid=3: reacting to signal 3
11-24 20:52:39.757: I/dalvikvm(842): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:39.877: I/Process(842): Sending signal. PID: 842 SIG: 9
11-24 20:52:41.037: I/dalvikvm(857): threadid=3: reacting to signal 3
11-24 20:52:41.107: I/dalvikvm(857): Wrote stack traces to '/data/anr/traces.txt'
11-24 20:52:41.246: D/dalvikvm(857): GC_FOR_ALLOC freed 70K, 3% free 9121K/9347K, paused 68ms