현재 개발하고 있는 어플의 기능 중에 폰에 SMS가 도착하면 문자의 내용에 따라 알림 bar에 notification을 발생하는 기능을 구현중입니다.
에뮬레이터에서 앱을 구동하고 DDMS를 사용해서 문자를 보냈는데 다음 Permission 에러가 뜹니다.
에뮬레이터 타겟은 2.2입니다.
Permission Denial: broadcasting Intent { act=android.provider.Telephony.SMS_RECEIVED (has extras) } from com.android.phone (pid=113, uid=1001) requires android.permission.RECEIVE_SMS due to receiver com.mkmtc/com.mkmtc.NotifSmsReceiver
BroadcastReceiver를 상속하는 NotifSmsReceiver를 만들었고, 내용은 다음과 같습니다.
public class NotifSmsReceiver extends BroadcastReceiver {
private final String tag = getClass().getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i(tag, "sms received");
}
}
Mainfest에 Receiver 등록하고 Permission도 설정했습니다.
- Manifest 파일
...
...
<receiver android:name=".NotifSmsReceiver" >
<intent-filter >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>




저같은경우는
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxxxxx"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<application ........>
</application>
</manifest>
위와같은 위치에 퍼미션을 추가했습니다.