I can`t do any action on new activity
I am new to android. I would like to ask you some question.
When I calling new activity from main activity by commands
Intent myIntent = new Intent(v.getContext(), PolarView.class);
//startActivityForResult(myIntent, 0);
startActivityForResult(myIntent, 0);
finish();
then in new activity I can't do any actions, e.g. such as button click
Both
Button btnSeven = (Button) this.findViewById(R.id.btn7);
btnSeven.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
InputStr = InputStr + "7";
InputViewField.setText(InputStr);
}
});
}
and
public void btn7_click(View v) {
InputStr = InputStr + "7";
InputViewField.setText(InputStr);
}
having defined android:onClick="btn7_click" in activity`s layout where InputViewField is EditText object
In the first case new activity does not start, in the second case when I press this button, aplication crashes.
could you please help me?
Here is some last peace of logcat after change
StartActivityForResult()
to
StartActivity()
Logcat:
D/MediaScanner( 153): opendir /system/media/ failed, errno: 2
D/MediaScanner( 153): prescan time: 25225ms
D/MediaScanner( 153): scan time: 162ms
D/MediaScanner( 153): postscan time: 48ms
D/dalvikvm( 109): GC freed 1920 objects / 95640 bytes in 160ms
D/MediaScanner( 153): total time: 25435ms
D/MediaScannerService( 153): done scanning volume internal
D/MediaScannerService( 153): start scanning volume external
D/dalvikvm( 52): GREF has increased to 301
I/ActivityManager( 52): Starting activity: Intent { cmp=complex.ComplexCalc/.PolarView }
I/ActivityManager( 52): Displayed activity complex.ComplexCalc/.PolarView: 1414 ms (total 1414 ms)
V/MediaScanner( 153): pruneDeadThumbnailFiles... android.database.sqlite.SQLiteCursor@43bc30b8
V/MediaScanner( 153): /pruneDeadThumbnailFiles... android.database.sqlite.SQLiteCursor@43bc30b8
D/MediaScanner( 153): prescan time: 1509ms
D/MediaScanner( 153): scan time: 405ms
D/MediaScanner( 153): postscan time: 323ms
D/MediaScanner( 153): total time: 2237ms
D/MediaScannerService( 153): done scanning volume external
D/AndroidRuntime( 223): Shutting down VM
W/dalvikvm( 223): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime( 223): Uncaught handler: thread main exiting due to uncaught exception
D/dalvikvm( 223): GC freed 3456 objects / 221888 bytes in 153ms
E/AndroidRuntime( 223): java.lang.IllegalStateException: Could not execute method of the activity
E/AndroidRuntime( 223): at android.view.View$1.onClick(View.java:2031)
E/AndroidRuntime( 223): at android.view.View.performClick(View.java:2364)
E/AndroidRuntime( 223): at android.view.View.onTouchEvent(View.java:4179)
E/AndroidRuntime( 223): at android.widget.TextView.onTouchEvent(TextView.java:6541)
E/AndroidRuntime( 223): at android.view.View.dispatchTouchEvent(View.java:3709)
E/AndroidRuntime( 223): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime( 223): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime( 223): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime( 223): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime( 223): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime( 223): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime( 223): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
E/AndroidRuntime( 223): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
E/AndroidRuntime( 223): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
E/AndroidRuntime( 223): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
E/AndroidRuntime( 223): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
E/AndroidRuntime( 223): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 223): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 223): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 223): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 223): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 223): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 223): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 223): at complex.ComplexCalc.PolarView.btn7_click(PolarView.java:266)
E/AndroidRuntime( 223): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 223): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 223): at android.view.View$1.onClick(View.java:2026)
E/AndroidRuntime( 223): ... 23 more
E/AndroidRuntime( 223): Caused by: java.lang.NullPo开发者_JS百科interException
E/AndroidRuntime( 223): ... 27 more
I/Process ( 52): Sending signal. PID: 223 SIG: 3
I/dalvikvm( 223): threadid=7: reacting to signal 3
I/dalvikvm( 223): Wrote stack trace to '/data/anr/traces.txt'
I/ARMAssembler( 52): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x46eae8:0x46eba4] in 1562593 ns
I/ARMAssembler( 52): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x46eba8:0x46ed70] in 1903198 ns
I/Process ( 223): Sending signal. PID: 223 SIG: 9
I/ActivityManager( 52): Process complex.ComplexCalc (pid 223) has died.
I/WindowManager( 52): WIN DEATH: Window{43cc3920 complex.ComplexCalc/complex.ComplexCalc.PolarView paused=false}
E/gralloc ( 52): [unregister] handle 0x481778 still locked (state=40000001)
I/UsageStats( 52): Unexpected resume of com.android.launcher while already resumed in complex.ComplexCalc
W/InputManagerService( 52): Got RemoteException sending setActive(false) notification to pid 223 uid 10024
I think part of your problem is that you are using startActivityForResult(..), when in fact you should be using startActivity(..), because your new activity might not be returning anything.
However, without error logs its difficult to tell what is really happening
精彩评论