0

I am following this tutorial but when I add the code to eclipse, everywhere the "i" int is called, eclipse gives the error "int cannot be converted to a boolean". Yet that is how it is in the code. How can I fix this without ruining the code or can I bypass that check? I've looked all over the internet on how to recieve sms and they all are the same. I get the same error in the code. Here's the link to the tutorial:

Receive SMS tutorial

I've searched all over stack overflow as well and every code I've found gives me the same error in eclipse.

EDIT 6/23/13: Here's my code. I've fixed the "i" int issue but now I'm getting errors on lines 33, 35, and 41. "Unreachable code"

SMSReceiver:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;

public class SMSReceiver extends BroadcastReceiver
{
 private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
 private World world;

 public SMSReceiver(World paramWorld)
 {
this.world = paramWorld;
 }

 public void onReceive(Context paramContext, Intent paramIntent)
{
    Object[] arrayOfObject;
    SmsMessage[] arrayOfSmsMessage;
    int i;
    if (paramIntent.getAction().equals("android.provider.Telephony.SMS_RECEIVED"))
{
  Bundle localBundle = paramIntent.getExtras();
  if (localBundle != null)
  {
    arrayOfObject = (Object[])localBundle.get("pdus");
    arrayOfSmsMessage = new SmsMessage[arrayOfObject.length];
    i = 0;
    if (i < arrayOfObject.length)
      break label68;
    if (arrayOfSmsMessage.length <= -1)
      break label90;
  }
}
label68: label90: for (this.world.haveUnreadMessage = true; ; this.world.haveUnreadMessage = false)
{
  return;
  arrayOfSmsMessage[i] = SmsMessage.createFromPdu((byte[])arrayOfObject[i]);
  i++;
  break;
}
}
 }
4

2 回答 2

2

如果您正在按照您链接到的教程进行操作,那么这条线似乎有问题。

   for (int i = 0; i &lt; pdus.length; i++) {

&lt;应该替换为<

于 2013-06-23T01:34:45.470 回答
1

而不是“&Lt”尝试“<”

于 2013-06-23T01:34:47.133 回答