내 질문은 어리석은 것처럼 보이지만 SMS 수신시 간단한 코드를 사용하여 Toast
을 만들지 만 내 건배는 불가능하다.broadcastreceiver와 건배를 할 수 없다. onReceive를 호출 할 수 없다.
내 Android 매니페스트 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.romain.assistantvocal" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<receiver class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<activity
android:name=".MyActivity"
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 class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
그리고 여기 내 클래스 SMSReceiver :
package com.example.romain.assistantvocal;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.telephony.gsm.SmsMessage;
import android.widget.Toast;
import java.util.Locale;
/**
* Created by romain on 26/09/2014.
*/
public class SMSReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Toast.makeText(context,"gg romstan",Toast.LENGTH_LONG).show();
}
}
가 귀하의 답변에 미리 감사드립니다.
'intent-filter android : priority = "100"> 100 to like'6565' –
class = "com.example.romain.SMSReceiver"'를 제거하고 두 번 선언하지 마십시오. – njzk2