0

音声通話をキャプチャする簡単なブロードキャスト レシーバーを作成しようとしています。以下は私のレシーバークラスとマニフェストファイルです。実行しようとするたびに、通話の直後に仮想デバイスが切断されます。私は何を間違っていますか???

package com.example.example06;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class MyPhoneReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "A phone call was received!", Toast.LENGTH_LONG).show();
    }
}

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.example06"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <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" >
        <receiver 
            android:name="MyPhoneReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" ></action>
            </intent-filter>            
        </receiver>                
    </application>

</manifest>
4

1 に答える 1

0

マニフェストを次のように変更してください:

            <receiver
              android:name="com.example.android.blah.MyPhoneReceiver"
              android:exported="false" >
               <intent-filter>
                 <action android:name="android.intent.action.PHONE_STATE" ></action>
               </intent-filter>
           </receiver>
于 2013-10-28T20:33:46.467 に答える