Broadcat レシーバー アプリケーションを 1 つ作成しています。その中で、次のエラーが発生しています
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (MyPhoneCall, String, int)
Java コード:
package com.example.myphonecall;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
public class MyPhoneCall extends BroadcastReceiver {
@
Override
public void onReceive(Context context, Intent intent) {
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);
Toast.makeText(this, "Getting Call from " + phoneNumber, Toast.LENGTH_LONG).show();
}
}
}
}