未设置意图,空 return

Intent not set,null return

(机器翻译)
我使用此代码启动 vpn 服务。
代码首先检查用户名和密码值不为空,然后VPN服务运行
我的问题是未设置意图。
在调试器中,intent 值为 null
问题出在哪里?

OnCheckedChangeListener connect=new OnCheckedChangeListener() 
{

    @Override
    public void onCheckedChanged(CompoundButton arg0, boolean arg1)
    {
        str_user=User.getText().toString();
        str_pass=Pass.getText().toString();

        if(str_user.matches(""))
        {
            Toast.makeText(getApplicationContext(),"please inter username" , Toast.LENGTH_LONG).show();
            User.setFocusable(true);
            Off_On.setChecked(false);
            return;
        }
        else if(str_pass.matches(""))
        {
            Toast.makeText(getApplicationContext(),"please inter password" , Toast.LENGTH_LONG).show();
            Pass.setFocusable(true);
            Off_On.setChecked(false);
            return;
        }
        else if(arg1==true)
        {
            Boolean s=false;
            s=Internet_state();
            if(!s)
            {
                Toast.makeText(getApplicationContext(), "please check internet connection", Toast.LENGTH_LONG).show();
                Off_On.setChecked(false);
                return;
            }
            else
            {
                Intent intent = VpnService.prepare(MainActivity.this);
                if (intent != null) {
                    startActivityForResult(intent, 0);
                } 

            }

        }
    }


};

prepare(Context) 方法returns null,因为 VPN 应用程序已经准备就绪。

Prepare to establish a VPN connection. This method returns null if the VPN application is already prepared or if the user has previously consented to the VPN application. Otherwise, it returns an Intent to a system activity

如果 VPN 应用已经准备就绪,请查看要遵循的步骤:here