0

私はアンドロイドが初めてです。私はブロードキャストレシーバーに取り組んでいます。発信通話をリッスンするレシーバーを作成したいと考えています。私が期待していたのは、発信コールが行われたときに logcat "It is Ok" を書き込むことです。ただし、ログに「nativegetenabledtags からの予期しない値」というメッセージが表示されます。

以下は私のマニフェストファイルです。

<uses-permission android:name="android.permission.READ_PHONE_STATE" >
    </uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="de.vogella.android.receiver.phone.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name="MyPhoneReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" >
                </action>
            </intent-filter>
        </receiver>

    </application>

以下はレシーバークラスです

 import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;

public class MyPhoneReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Bundle extras = intent.getExtras();
        if (extras != null) {
              String state = extras.getString(TelephonyManager.EXTRA_STATE);
              Log.w("MY_DEBUG_TAG", state);
              if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                String phoneNumber = extras
                    .getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                Log.w("MY_DEBUG_TAG", phoneNumber);
              }
            }  
            }

}

解決策を教えてください。

4

2 に答える 2

0

この回答を確認してください: nativeGetEnabledTags からの予期しない値: 0

このフィルタを LogCat に追加します: ^(?!. (nativeGetEnabledTags))。$

これはツールの最新リビジョンで導入されたバグです... Google は次のバージョンでの修正に取り組んでいます

于 2013-06-10T09:53:05.153 に答える
0

これが正確な理由かどうかはわかりませんが、クラス名の前にドット (.) を付ける必要があります。以下のように。

<receiver android:name=".MyPhoneReceiver" >

これがあなたの正確な問題かどうかはわかりませんが、. これが理由でない場合、他の問題が発生します

于 2013-06-10T09:44:09.120 に答える