请帮帮我,我无法解决这个jave代码。
编译器错误是:
这是我的代码段:
public class CallListener extends PhoneStateListener {
public static String nameOrNumber = "";
private Context context;
boolean phonebook;
boolean unknowncall;
public CallListener(Context paramContext) {
this.context = paramContext;`
}
public void onCallStateChanged(int paramInt, String paramString) {
switch (((AudioManager) this.context.getSystemService("audio")).getRingerMode()) {
default:
case 0:
case 1:
case 2:
}
while (true) {
SharedPreferences localSharedPreferences = this.context.getSharedPreferences("com.appbasic.callername", 0);
this.unknowncall = localSharedPreferences.getBoolean("unknowncall", true);
this.phonebook = localSharedPreferences.getBoolean("phonebook", true);`
switch (paramInt) {
default: return;
Log.i("MyApp", "Silent mode");
paramInt = 0;
continue;
Log.i("MyApp", "Vibrate mode");
paramInt = 0;
continue;
Log.i("MyApp", "Normal mode");
case 1:
}
}
String str1 = paramString.substring(3);`
Log.i("phonestate", paramInt + "," + str1);
String str2;
if ((this.phonebook) && (this.unknowncall)) {
str2 = null;
if (1 == paramInt)
str2 = CallUtils.lookup(this.context, str1);
if ((str2 == null) || (str2 == ""))
str2 = str1;
label224: if (str2 != null)
break label393;
}
label393: String str4;
String str5;
for (String str6 = "";; str6 = str4 + " " + str2 + " " + str5) {
Intent localIntent = new Intent(this.context, PhoneService.class);
localIntent.putExtra(PhoneService.NAME_KEY, str6);
nameOrNumber = str6;
if (paramInt != 0)
this.context.startService(localIntent);
if (paramInt != 0)
break;
Utils.stopService(this.context, PhoneService.class);
return;
if ((this.phonebook) && (!this.unknowncall)) {
str2 = null;
if (1 != paramInt)`
break label224;
str2 = CallUtils.lookup(this.context, str1);
break label224;
}
boolean bool1 = this.phonebook;
str2 = null;
if (bool1)
break label224;
boolean bool2 = this.unknowncall;
str2 = null;
if (!bool2)
break label224;
String str3 = null;`
if (1 == paramInt)
str3 = CallUtils.lookup(this.context, str1);
if (str3 == null) {
str2 = str1;
break label224;
}
str2 = null;
break label224;
str4 = LockStore.getMsgBefore(this.context);
str5 = LockStore.getMsgAfter(this.context);
}
}
}
答案 0 :(得分:0)
Java似乎不允许在标记行中声明:
ExampleLabel: String exampleString; // this won't compile in my IDE
据我所知,标签是针对循环(和条件?)制作的,以突破嵌套代码中的多个级别。 它们不应该用作替代品。
尝试删除label393 - 您只在上面一行的条件下使用它一次,所以无论如何都没有必要。我想。
除了你的错误:如果你达到了你的代码无法编译的程度,你不知道为什么和其他人在看到它时会摸不着头脑 - 是时候重新设计和重构你的代码了!
从变量的有用名称开始,避免使用标签(你真的需要它们吗?为什么?)。
如果您需要有关标记分支语句的帮助,请查看此处:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html