2.1 플랫폼을 사용하고 있습니다. 에뮬레이터에서 모든 SMS를 검색하는 중입니다. 아니요 컴파일 오류, 아니요 Logcat 오류 내 코드에 포함되어 있습니다 .ModifyMSMS에 대한 권한을 매니페스트 파일에 포함 시켰습니다. 코드를 실행해도 ListView에 표시되지 않습니다. 내 XML 파일에는 하나의 ListView 만 있습니다. 해당 ListView에서 에뮬레이터에서 모든 SMS 형식 (번호 : Sms 본문)을 표시하려고합니다.Sms 검색 중 작동하지 않습니까?
코드
public class SMSActivity extends Activity {
/** Called when the activity is first created. */
ListView lview;
String Body = "" ;
int Number;
ArrayList<String> smslist=new ArrayList<String>();
ArrayAdapter<String> itemAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lview =(ListView)findViewById(R.id.lv);
itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,smslist);
lview.setAdapter(itemAdapter);
ContentResolver cr = getContentResolver();
Cursor c = cr.query(Uri.parse("content://sms/"), new String[] { "_id", "address", "date", "body","read" },"_id = "+null, null, null);
while(c.moveToNext()){
Number = c.getInt(c.getColumnIndexOrThrow("address"));
Body = c.getString(c.getColumnIndexOrThrow("body")).toString();
smslist.add(Number + "\n" + Body);
}
itemAdapter.notifyDataSetChanged();
c.close();
}
}
어떻게이 문제를 해결하기 위해?
를 사용하여 열 이름을 조회 할 수 있습니다
.. : http://android10.org/index.php/articlesfullapplications/241-sms-messaging-in-android-send - 및 - 수신 및 http://stackoverflow.com/a/11356430/1168654 그것은 당신을 도울 수 있습니다. –
이 사이트는 에뮬레이터간에 SMS를 보내고 가져 오는 중입니다 ..... 내 코드를 확인하십시오 ... – Hari
안녕하세요, 지난 두 번째 링크에 대해 잊어 버렸습니다. http://stackoverflow.com/a/11356430/1168654 –