전화가 SMS 메시지를받을 때 작은 응용 프로그램을 쓰고 있습니다. 발신자 전화 번호와 SMS 본문이 TextView
에 표시됩니다. SMS BoardcastReceiver
과 Activity
이 있습니다.TextView에 SMS 메시지 표시
여기 내 SMS 수신기입니다.
다음import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class BroadcastNewSms extends Activity {
TextView SMSm;
String phoneNumber1;
String SMSBody1;
public void getSmsDetails(String phoneNumber, String SMSBody) {
phoneNumber1 = phoneNumber;
SMSBody1 = SMSBody;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SMSm = (TextView) findViewById(R.id.etSmsBody);
SMSm.setText("Phone Number: " + phoneNumber1 + " " + "SMS: " +
SMSBody1);
}
}
내 매니페스트는 다음과 같습니다 :
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="kobi.avshalom.recivesms.BroadcastNewSms"
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 android:name="kobi.avshalom.recivesms.IncomingSms" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_SMS" >
</uses-permission>
<uses-permission android:name="android.permission.READ_SMS" >
</uses-permission>
<uses-permission android:name="android.permission.SEND_SMS" >
</uses-permission>
그러나 문제/오류가 무엇입니까? –
@Prince 디버그하십시오. 질문이 없습니다. –
@SherifelKhatib 무엇? OP는 문제를 지정하지 않으므로 이에 대해 묻습니다. –