如何使用_L标签?

时间:2016-02-16 18:12:14

标签: android

这是我的班级,但是我遇到了所有_L标签的问题,即_L1,_L3它显示我的颜色并且说这不是一个声明。我该怎么办呢?我已经尝试了创建objetcs,Lables,Vairiable的所有方法,但似乎没有任何工作。任何帮助将不胜感激。

public class Util {

        public static void launchSTK(Activity activity) {
            Intent intent = activity.getPackageManager().getLaunchIntentForPackage("com.android.stk");
            if (intent == null) goto _L2;else goto _L1
            _L1:
            activity.startActivity(intent);
            _L4:
            return;
            _L2:
            try {
                Intent intent1 = new Intent();
                intent1.addFlags(0x10000000);
                intent1.addCategory("android.intent.category.LAUNCHER");
                intent1.setAction("android.intent.action.MAIN");
                intent1.setType("text/plain");
                intent1.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkLauncherActivity"));
                activity.startActivity(intent1);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception) {
            }
            try {
                Intent intent2 = new Intent();
                intent2.addFlags(0x10000000);
                intent2.addCategory("android.intent.category.LAUNCHER");
                intent2.setAction("android.intent.action.MAIN");
                intent2.setType("text/plain");
                intent2.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkMain"));
                activity.startActivity(intent2);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception1) {
            }
            if (!(activity instanceof TumapesaHome))goto _L4;else goto _L3
            _L3:
            ((TumapesaHome) activity).makeSnackBar();
            return;
            ActivityNotFoundException activitynotfoundexception2;
            activitynotfoundexception2;
            try {
                Intent intent3 = new Intent();
                intent3.addFlags(0x10000000);
                intent3.addCategory("android.intent.category.LAUNCHER");
                intent3.setAction("android.intent.action.MAIN");
                intent3.setType("text/plain");
                intent3.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkLauncherActivity"));
                activity.startActivity(intent3);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception3) {
            }
            try {
                Intent intent4 = new Intent();
                intent4.addFlags(0x10000000);
                intent4.addCategory("android.intent.category.LAUNCHER");
                intent4.setAction("android.intent.action.MAIN");
                intent4.setType("text/plain");
                intent4.setComponent(new ComponentName("com.android.stk", "com.android.stk.StkMain"));
                activity.startActivity(intent4);
                return;
            } catch (ActivityNotFoundException activitynotfoundexception4) {
            }
            if (activity instanceof TumapesaHome) {
                ((TumapesaHome) activity).makeSnackBar();
                return;
            }
            goto _L4
        }
    }

这是错误

Error:(20, 29) error: illegal start of expression
Error:(20, 34) error: not a statement
Error:(20, 38) error: 'else' without 'if'
Error:(20, 43) error: illegal start of expression
Error:(20, 51) error: ';' expected
Error:(48, 49) error: illegal start of expression
Error:(48, 54) error: not a statement
Error:(48, 58) error: 'else' without 'if'
Error:(48, 63) error: illegal start of expression
Error:(48, 71) error: ';' expected
Error:(53, 9) error: not a statement
Error:(80, 9) error: illegal start of expression
Error:(80, 14) error: not a statement
Error:(80, 17) error: ';' expected
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 4.44 secs
Information:15 errors
Information:0 warnings
Information:See complete output in console

1 个答案:

答案 0 :(得分:0)

Java不支持goto。它有关键字但不实现它。标签由break等语句使用。

在您的情况下,错误是(除了使用不受支持的goto),而不是在goto _L1goto _L3goto _L4之后添加分号。

gotos tend to make a lot of mess(这就是Java不支持它们的原因)。