Android错误识别

时间:2011-08-11 06:30:40

标签: android

请识别此错误。

08-11 12:34:20.757: INFO/ActivityManager(68): Starting: Intent { cmp=com.acdroid/.activityclasses.ConditionalPolicyEntry (has extras) } from pid 
08-11 12:34:20.966: DEBUG/dalvikvm(369): GC_EXTERNAL_ALLOC freed 172K, 51% free 2706K/5511K, external 2116K/2137K, paused  
08-11 12:34:21.276: DEBUG/AndroidRuntime(369): Shutting down VM
08-11 12:34:21.276: WARN/dalvikvm(369): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-11 12:34:21.276: ERROR/AndroidRuntime(369): FATAL EXCEPTION: main
08-11 12:34:21.276: ERROR/AndroidRuntime(369): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.acdroid/com.acdroid.activityclasses.ConditionalPolicyEntry}: java.lang.NullPointerException
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.os.Looper.loop(Looper.java:123)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at java.lang.reflect.Method.invokeNative(Native Method)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at java.lang.reflect.Method.invoke(Method.java:507)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at dalvik.system.NativeStart.main(Native Method)
08-11 12:34:21.276: ERROR/AndroidRuntime(369): Caused by: java.lang.NullPointerException
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at com.acdroid.activityclasses.ConditionalPolicyEntry.onCreate(ConditionalPolicyEntry.java:41)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-11 12:34:21.276: ERROR/AndroidRuntime(369):     ... 11 more
08-11 12:34:21.296: WARN/ActivityManager(68):   Force finishing activity com.acdroid/.activityclasses.ConditionalPolicyEntry
08-11 12:34:21.317: WARN/ActivityManager(68):   Force finishing activity com.acdroid/.activityclasses.PolicyEntryMain
08-11 12:34:21.823: WARN/ActivityManager(68): Activity pause timeout for HistoryRecord{406da960 com.acdroid/.activityclasses.ConditionalPolicyEntry}
08-11 12:34:23.077: INFO/Process(369): Sending signal. PID: 369 SIG: 9
08-11 12:34:23.097: INFO/ActivityManager(68): Process com.acdroid (pid 369) has died.
08-11 12:34:23.119: ERROR/InputDispatcher(68): channel '4073f5d0 com.acdroid/com.acdroid.ACDroid (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
08-11 12:34:23.119: ERROR/InputDispatcher(68): channel '4073f5d0 com.acdroid/com.acdroid.ACDroid (server)' ~ Channel is unrecoverably broken and will be disposed!
08-11 12:34:23.167: INFO/WindowManager(68): WIN DEATH: Window{4073f5d0 com.acdroid/com.acdroid.ACDroid paused=false}
08-11 12:34:23.227: INFO/WindowManager(68): WIN DEATH: Window{406e93b8 com.acdroid/com.acdroid.activityclasses.PolicyEntryMain paused=true}
08-11 12:34:23.316: ERROR/InputDispatcher(68): Received spurious receive callback for unknown input channel.  fd=196, events=0x8
08-11 12:34:24.028: WARN/InputManagerService(68): Got RemoteException sending setActive(false) notification to pid 369 uid 10051
08-11 12:34:24.297: INFO/ARMAssembler(68): generated scanline__00000177:03515104_00001002_00000000 [ 87 ipp] (110 ins) at [0x445ed848:0x445eda00] in 713146 ns
08-11 12:39:05.969: DEBUG/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
08-11 12:44:06.023: DEBUG/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
08-11 12:49:06.076: DEBUG/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
08-11 12:54:06.117: DEBUG/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol

在activityA中,

 final Intent conditionalIntent = new Intent(this,ConditionalPolicyEntry.class);
         btn_ok.setOnClickListener(new View.OnClickListener() 
            {
                @Override
                public void onClick(View v) 
                {

                    conditionalIntent.putExtra("user_id",1);
                    startActivity(conditionalIntent);
                }
            });

在activityB中,

 Bundle extrasFromCondition = getIntent().getExtras();
    myPolicy.setID(extrasFromCondition.getInt("user_id"));  // line 41

PS:每当我放置//时,都会通过get函数跟踪错误。 认为我无法传递数据。

政策类如下:

public class Policy{
int ID;
int user_type;
public int getID() 
{
    return ID;
}
public void setID(int iD) {
    this.ID = iD;
}

public int getUser_type() {
    return user_type;
}
public void setUser_type(int userType) {
    this.user_type = userType;
}}

5 个答案:

答案 0 :(得分:2)

在第41行检查是否有空:

at com.acdroid.activityclasses.ConditionalPolicyEntry.onCreate(ConditionalPolicyEntry.java:41)

或者如果你可以显示代码......

答案 1 :(得分:2)

您将获得nullpointer异常请查看

ConditionalPolicyEntry.onCreate(ConditionalPolicyEntry.java:41)

答案 2 :(得分:2)

你的代码在第41行的文件ConditionalPolicyEntry.java中有空指针

com.acdroid.activityclasses.ConditionalPolicyEntry.onCreate(ConditionalPolicyEntry.java:41)

答案 3 :(得分:2)

conditionalIntent.putExtra("user_id","1");
startActivity(conditionalIntent);

myPolicy.setID(Integer.parseInt(extrasFromCondition.getString("user_id")));

什么是myPolicy。如果它是一个视图,那么方法是setId,而不是setID

答案 4 :(得分:0)

既然你说过“我已经添加了上面的代码。我认为这是putExtras问题,但我错了。我可以用myPolicy.setID(...)上面的Log.i()打印捆绑数据。” -

,错误位于以下行:

 myPolicy.setID(extrasFromCondition.getInt("user_id"));  // line 41

可以得出的唯一结论是引用myPolicy为null。你在哪里分配myPolicy?