如何得到我和另一个号码短信java android之间的对话

0mkxixxg  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(278)

我想把对话放在我和另一个号码之间我已经有他的短信了
按此代码

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);
        String hi = getIntent().getExtras().getString("number");
        String name =getIntent().getExtras().getString("name");
        ArrayList<Messagetwo> contacts = new ArrayList<>();
        MessageListAdapter adapter =new MessageListAdapter(this,R.layout.message_activity,contacts);
        listView = findViewById(R.id.listview);
        listView.setAdapter(adapter);
        String[] phoneNumber = new String[] { hi }; //the wanted phone number
        cursor = getContentResolver().query(Uri.parse("content://sms"), new String[] { "_id", "thread_id", "address", "person", "date","body", "type" }, "address=?", phoneNumber, null);
        cursor.moveToLast();
        while (!cursor.isBeforeFirst()){
            if (name==null){
                x=hi;
            }else {
                x.equals(name);
            }
            y=cursor.getString(cursor.getColumnIndex("body"));
            z=cursor.getString(cursor.getColumnIndex("date"));
            SimpleDateFormat formatter  = new SimpleDateFormat("EEE, dd/MM/yyyy \n hh aa:mm");
            z = formatter.format(new Date(Long.parseLong(z)));
            Messagetwo SMS= new Messagetwo(x,y,z);
            contacts.add(SMS);
            cursor.moveToPrevious();
        }
}
}

这就是结果
我该怎么做才能得到我的短信呢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题