GetLaunchIntentForPackage jumps between the two modules of Android Studio, and the intent is null, which has been resolved

Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.app2");
        if (intent == null) {
            Toast.makeText(getApplicationContext(),"没有安装该app",Toast.LENGTH_SHORT).show();
        } else {
            startActivity(intent);
        }

This code can jump from the Layout of this module to the Layout of com.example.app2. However, after two hours of testing, the intent is still null when jumping on Android Studio, but it can be jumped after testing it on a physical machine. The reason is that some Android virtual machines of Android Studio cannot be redirected. Just connect to the Android phone and run it on the phone.

I downloaded three simulators and tested it. Samsung’s simulators can jump between modules.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43873198/article/details/108876483