게시판에서 얻은 기본 BroadcastReceiver 소스가..
기본 코드임에도 불구하고 수신이 안되고 있습니다.
manifest xml 에도 등록했는데요... 헐...
모가 빠진건지..알수가 없네요..왜 안될까요?
package pkg.BasicSMS;
import android.app.Activity;
import android.os.Bundle;
public class BasicSMS extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
그리고..클래스 새로 추가하고..
package pkg.BasicSMS;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SMS_Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
StringBuilder sb = new StringBuilder();
Bundle bundle = intent.getExtras();
if(bundle != null) {
Object[] pdusObj = (Object[])bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdusObj.length];
for(int i = 0; i < pdusObj.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdusObj[i]);
}
for(int i = 0; i < messages.length; i++) {
sb.append("[SMS 수신]n");
sb.append("발신번호: " + messages[i].getOriginatingAddress() + "n");
sb.append("내용: " + messages[i].getDisplayMessageBody());
}
Toast.makeText(context, sb.toString(), Toast.LENGTH_SHORT).show();
//((TextView) ((Activity) context).findViewById(R.id.txtSMS)).setText(sb.toString());
Log.d(context.toString(), sb.toString());
}
}
}
manifest xml 은...당근 ...아래...처럼.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pkg.BasicSMS"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".BasicSMS"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<receiver android:name="SMS_Receiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</manifest>
모 때문에 안되는지....도움의 손길을~~~
줘도....못먹는 증상이....헐~




실행포인트가 진입을 안하고 있으니...대략 난감...갤스 붙여서 테스트해 보고 있습니다.