0

アプリケーションは、エミュレーター/電話の再起動時にのみ強制終了を示します。2つのブロードキャストレシーバー1があり、電話の状態を確認して通話に応答し、もう1つは通知アイコンを上部に保持します。電話の状態を監視する受信者は、起動時にのみ次の例外を発生させます。それ以外の場合、アプリは正常に動作します。ログを以下に示します

05-20 12:48:15.688: INFO/Andros:AnsTheCall:receiver(218): initialised the receiver
05-20 12:48:15.707: WARN/dalvikvm(218): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-20 12:48:15.827: ERROR/AndroidRuntime(218): FATAL EXCEPTION: main
05-20 12:48:15.827: ERROR/AndroidRuntime(218): java.lang.RuntimeException: Unable to start receiver com.andros.AnsTheCall.AnsTheCallReceiver: java.lang.NullPointerException
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.os.Looper.loop(Looper.java:123)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at java.lang.reflect.Method.invokeNative(Native Method)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at java.lang.reflect.Method.invoke(Method.java:521)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at dalvik.system.NativeStart.main(Native Method)
05-20 12:48:15.827: ERROR/AndroidRuntime(218): Caused by: java.lang.NullPointerException
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at com.andro.AnsTheCall.AnsTheCallReceiver.onReceive(AnsTheCallReceiver.java:37)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-20 12:48:15.827: ERROR/AndroidRuntime(218):     ... 10 more

助けてください

public class AnsTheCallReceiver extends BroadcastReceiver {

public static final String TAG = "Andros:AnsTheCall:receiver";
public selectedTabType attentFlag = selectedTabType.TYPE_INVALID;

private Intent AnsTheCallServiceIntent = null;
public String contactName = null;
public String contactEmail = "";
public int PhoneNumberCount= 0;

@Override
public void onReceive(Context context, Intent intent) {

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    // Check phone state
    String phone_state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
    String lastPhoneNumber = null;
    Log.i(TAG,"initialised the receiver");

    if (phone_state.equals(TelephonyManager.EXTRA_STATE_RINGING) && prefs.getBoolean("appEnabled", false)) {
        int is_starred = isStarred(context, phoneNumber);
4

1 に答える 1

1

com.andro.AnsTheCall.AnsTheCallReceiver.onReceive(AnsTheCallReceiver.java:37これが原因でサービスが強制的に終了していることを確認してください。

12:48:15.827:ERROR / AndroidRuntime(218):原因:java.lang.NullPointerException 05-20 12:48:15.827:ERROR / AndroidRuntime(218):com.andro.AnsTheCall.AnsTheCallReceiver.onReceive(AnsTheCallReceiver。 java:37)05-20 12:48:15.827:

于 2012-05-20T08:30:20.270 に答える