0

Java ヌル ポインター例外が発生しています。レシーバー エラーを開始できません。

マイ LogCat

04-23 21:55:16.889: I/TextView(8039): *****onCrecateContextMenu::isInputMethodTarget:true, isIMEChangable;true
04-23 21:55:25.479: D/AndroidRuntime(8039): Shutting down VM
04-23 21:55:25.479: W/dalvikvm(8039): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-23 21:55:25.479: E/AndroidRuntime(8039): FATAL EXCEPTION: main
04-23 21:55:25.479: E/AndroidRuntime(8039): java.lang.RuntimeException: Unable to start receiver com.yp.iss_project.CbReceiver: java.lang.NullPointerException
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1809)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.app.ActivityThread.access$2400(ActivityThread.java:117)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:985)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.os.Looper.loop(Looper.java:130)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at java.lang.reflect.Method.invokeNative(Native Method)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at java.lang.reflect.Method.invoke(Method.java:507)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at dalvik.system.NativeStart.main(Native Method)
04-23 21:55:25.479: E/AndroidRuntime(8039): Caused by: java.lang.NullPointerException
04-23 21:55:25.479: E/AndroidRuntime(8039):     at com.yp.iss_project.CbReceiver.onReceive(CbReceiver.java:272)
04-23 21:55:25.479: E/AndroidRuntime(8039):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1798)
04-23 21:55:25.479: E/AndroidRuntime(8039):     ... 10 more
04-23 21:56:57.819: W/KeyCharacterMap(8162): No keyboard for id 0
04-23 21:56:57.819: W/KeyCharacterMap(8162): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
04-23 21:57:00.359: I/TextView(8162): *****onCrecateContextMenu::isInputMethodTarget:true, isIMEChangable;true
04-23 21:57:08.069: D/AndroidRuntime(8162): Shutting down VM
04-23 21:57:08.069: W/dalvikvm(8162): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-23 21:57:08.069: E/AndroidRuntime(8162): FATAL EXCEPTION: main
04-23 21:57:08.069: E/AndroidRuntime(8162): java.lang.RuntimeException: Unable to start receiver com.yp.iss_project.CbReceiver: java.lang.NullPointerException
04-23 21:57:08.069: E/AndroidRuntime(8162):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1809)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at andr oid.app.ActivityThread.access$2400(ActivityThread.java:117)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:985)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at android.os.Looper.loop(Looper.java:130)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at java.lang.reflect.Method.invokeNative(Native Method)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at java.lang.reflect.Method.invoke(Method.java:507)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at dalvik.system.NativeStart.main(Native Method)
04-23 21:57:08.069: E/AndroidRuntime(8162): Caused by: java.lang.NullPointerException
04-23 21:57:08.069: E/AndroidRuntime(8162):     at com.yp.iss_project.CbReceiver.onReceive(CbReceiver.java:273)
04-23 21:57:08.069: E/AndroidRuntime(8162):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1798)
04-23 21:57:08.069: E/AndroidRuntime(8162):     ... 10 more
04-23 21:59:10.639: I/TextView(8265): *****onCrecateContextMenu::isInputMethodTarget:true, isIMEChangable;true
04-23 21:59:19.979: D/AndroidRuntime(8265): Shutting down VM
04-23 21:59:19.979: W/dalvikvm(8265): threadid=1: thread exiting with uncaught exception (group=0x40018578)

私の放送受信機は

   public static String str;
    public static int my;
    public static String MSG = encrypt.message;
    public final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";

    public void onReceive(Context context, Intent intent) {
        //---get the CB message passed in---

        Bundle bundle = intent.getExtras();        
        SmsCbMessage[] msgs = null;

        if (bundle != null)  {
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsCbMessage[pdus.length];            
            for (int i=0; i<msgs.length; i++) {
                msgs[i] = SmsCbMessage.createFromPdu((byte[])pdus[i]);                
                str = ""; 
                str +="" +msgs[i].getGeographicalScope() + msgs[i].getMessageCode() + msgs[i].getMessageIdentifier() + msgs[i].getUpdateNumber();                     
                my = msgs[i].getGeographicalScope() + msgs[i].getMessageCode() + msgs[i].getMessageIdentifier() + msgs[i].getUpdateNumber();

                if(str != "")
                {
                Toast.makeText(context, "CB: " +str, Toast.LENGTH_LONG).show();
                Toast.makeText(context, "MY: " +my, Toast.LENGTH_LONG).show();

                {
                          String cipherText="";
                          for(int y=0;y<MSG.length();y++)
                          {

                               int charPosition = ALPHABET.indexOf(MSG.charAt(y));
                               int keyVal = (my + charPosition)%26;
                               char replaceVal = this.ALPHABET.charAt(keyVal);
                               cipherText += replaceVal;
                          }
                          Toast.makeText(context, "CipherText: " +cipherText, Toast.LENGTH_LONG).show();

                }

                }
                }
                abortBroadcast();  
                }
4

1 に答える 1

2

削除されました

public static String MSG = encrypt.message;

MSG のすべての出現箇所を

encrypt.message

私の間違いは、受信者クラスで宣言された MSG 値がヌルであるため、暗号化クラスから値 pf メッセージを渡すことでした。ヌル ポインター例外を受け取りました。

于 2013-04-28T16:57:48.347 に答える