我是 Android 的新手,我制作了 android 短信应用程序,
它不是错误但它无法接收长短信(超过 160 个字符),
这是我的 SMSReceiver 代码,我的错误代码在哪里?请帮我..
package com.tugas_akhir;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import model.SMS;
import com.niusounds.sqlite.SQLiteDAO;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SMSReceiver extends BroadcastReceiver
{
public SQLiteDAO dao;
public void onReceive(Context paramContext, Intent paramIntent)
{
Toast.makeText(paramContext, "SMS diterima", Toast.LENGTH_LONG).show();
Calendar localCalendar = Calendar.getInstance();
SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("HH:mm, dd MMM yyyy");
dao = SQLiteDAO.getInstance(paramContext, new Class[] { SMS.class });
Bundle localBundle = paramIntent.getExtras();
String str = "";
(SmsMessage[]) = null;
Object[] arrayOfObject = null;
SmsMessage[] arrayOfSmsMessage = null;
if (localBundle != null)
{
arrayOfObject = (Object[])localBundle.get("pdus");
arrayOfSmsMessage = new SmsMessage[arrayOfObject.length];
}
for (int i = 0; ; i++)
{
if (i >= arrayOfSmsMessage.length)
{
Toast.makeText(paramContext, "TERIMA SMS : " + str, Toast.LENGTH_SHORT).show();
return;
}
//insert into table
arrayOfSmsMessage[i] = SmsMessage.createFromPdu((byte[])arrayOfObject[i]);
SMS localSMS = new SMS();
str = arrayOfSmsMessage[i].getMessageBody().toString();
localSMS.setNoHp(arrayOfSmsMessage[i].getOriginatingAddress().toString());
localSMS.setPesan(arrayOfSmsMessage[i].getMessageBody().toString());
localSMS.setTime(localSimpleDateFormat.format(localCalendar.getTime()));
dao.insert(localSMS);
}
}
}
帮我..