开发者

android sending succesfully textview's text as a sms but receiving invalid chars on other emulator

I want to clearly explain what i did. I have a one listactivity which stores prepared messages like "Call me later!", "I will come soon"... When the user click the item, listitem (object) goes to other intent's textview via getintent().getserializable("comingstring");now textview stores this string via textview.setText(getintent().getserializable("comingstring").toString()) . There is no any problem here. I enter phone number(5554) which is other emulator, message is succesfully delivered but problem is when 开发者_C百科i look emulator 5554's inbox, i see the delivered message like " @ { & !' = | that kind of chars. Can you show me a solution? (I also tried sending prepared message(listitem's object) via mms.apk but the result is fail again. Message has succesfully sent but when i read other emulator's receiving message in inbox, i see only silly chars.)

Messages come from listactivity. In listactivity:

adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, messages); 
setListAdapter(adapter); 

public void onItemClick(AdapterView<?> parent, View v, int position,
                    long rowid) {
            itemMesaj = parent.getItemAtPosition(position).toString();
            SmsActivity.putExtra("itemMesaj", itemMesaj);
            startActivity(SmsActivity);
 }

In SmsActivity

itemMesaj =  (String)getIntent().getSerializableExtra("itemMesaj");txtMesaj = (TextView)findViewById(R.id.txtmesaj);txtMesaj.setText(itemMesaj);

public void onClick(View src) {
switch (src.getId()) {
case R.id.btnSend:
     messageinsend = txtMesaj.getText().toString();  
     Log.d("messagecheck", messageinsend);
     sendSMS("5556", messageinsend);
    break;
default:
    break;

}

I benefit sendSMS method from http://mobiforge.com/developing/story/sms-messaging-android. As i say, there is no problem for sending sms or receving only problem is receving text has invalid chars like " @ { & !' = |. If i try to send sendSms("5556","TRYING SOME TEXT") like this, there is no problem from receving side. I see the text like TRYING SOME TEXT.


The problem is while creating/getting the message from the listview.
Instead of this

itemMesaj = parent.getItemAtPosition(position).toString(); 

Try this

itemMesaj = adapter.getItem(position);

EDIT:
In onItemClick() paramters View v is the clicked view. So you can use that too to get the sms text. Like

TextView tv = (TextView)v;
String message = tv.gettext();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜