Meine zweite Aktivität startet nicht. Unten ist der Code :-
Erste Aktivität :-
package infy.route;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class main extends Activity {
/** Called when the activity is first created. */
Context mCtx;
final static int START =0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcomescreen);
mCtx = this;
Thread splashThread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while (waited < 2500) {
sleep(100);
waited += 100;
}
} catch (InterruptedException e) {
// do nothing
} finally {
finish();
Intent i = new Intent(mCtx,InfyRoutePlanner.class);
mCtx.startActivity(i);
((Activity)mCtx).startActivityForResult(i, 2);
}
}
};
splashThread.start();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == START)
{
Toast.makeText(mCtx, Integer.toString(resultCode), Toast.LENGTH_SHORT).show();
}
}
@Override
public void onDestroy(){
super.onDestroy();
finish();
}
}
Zweite Aktivität :-
package infy.route;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class InfyRoutePlanner extends Activity {
/** Called when the activity is first created. */
Context mCtx;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mCtx = this;
// Setting the buttons with their xml
Button btn1 = (Button)findViewById(R.id.btn1);
Button btn2 = (Button)findViewById(R.id.btn2);
// Button for Prepare Route By Address ( Line 30 is this one)
btn1.setOnClickListener(new OnClickListener(){
// @Override
public void onClick(View v)
{
// This will start the From Address Activity
Intent intent = new Intent(mCtx, FromAddress.class);
/*Start Activity*/
mCtx.startActivity(intent);
/*Start ActivityForResult*/
((Activity)mCtx).startActivityForResult(intent, 3);
}
});
// Action On Clicking Button 2
btn2.setOnClickListener(new OnClickListener(){
// @Override
public void onClick(View v)
{
// This will start the activity RoutePlanning using Lat and Long Values
Intent intent = new Intent(mCtx, RoutePlanning.class);
/*Start Activity*/
mCtx.startActivity(intent);
/*Start ActivityForResult*/
((Activity)mCtx).startActivityForResult(intent, 3);
}
});
}
}
Hier ist der Stack Tracer :-
02-18 20:10:02.253: DEBUG/AndroidRuntime(299): Shutting down VM
02-18 20:10:02.263: WARN/dalvikvm(299): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
02-18 20:10:02.263: ERROR/AndroidRuntime(299): Uncaught handler: thread main exiting due to uncaught exception
02-18 20:10:02.283: ERROR/AndroidRuntime(299): java.lang.VerifyError: infy.route.InfyRoutePlanner$1
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at infy.route.InfyRoutePlanner.onCreate(InfyRoutePlanner.java:30)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.os.Handler.dispatchMessage(Handler.java:99)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.os.Looper.loop(Looper.java:123)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at android.app.ActivityThread.main(ActivityThread.java:4203)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at java.lang.reflect.Method.invokeNative(Native Method)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at java.lang.reflect.Method.invoke(Method.java:521)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
02-18 20:10:02.283: ERROR/AndroidRuntime(299): at dalvik.system.NativeStart.main(Native Method)