我的Android Apk的服务器URL是什么?

我的Android Apk的服务器URL是什么?,android,server,apk,android-volley,Android,Server,Apk,Android Volley,我正在使用PHP JSON截取来验证我的登录活动。目前我正在提供本地主机和IP地址来测试我的应用程序(请在下面找到我的代码)。但是当生成APK时,应该给出什么URL?好心的导游 public class LoginActivitywithConnection extends Activity { private static final String TAG = "LoginActivitywithConnection"; private Button

我正在使用PHP JSON截取来验证我的登录活动。目前我正在提供本地主机和IP地址来测试我的应用程序(请在下面找到我的代码)。但是当生成APK时,应该给出什么URL?好心的导游

      public class LoginActivitywithConnection extends Activity {
        private static final String TAG = "LoginActivitywithConnection";
        private Button btnLogin;
        private Button btnLinkToRegister;
        private EditText usernameEditText;
        private EditText inputPassword;
        private ProgressDialog pDialog;
        private SessionManager session;
        private DbHandler db;
        String userType;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    Log.i(TAG, "entered");
    Intent i = this.getIntent();
    Bundle data = i.getExtras();
    if (data != null) {
        String buttonClicked = data.getString("ButtonClicked");
        if (buttonClicked.equals("asha")) {
            userType = "asha";
        } else if (buttonClicked.equals("anm")) {
            userType = "anm";
        } else if (buttonClicked.equals("doc")) {
            userType = "doc";
        } else if (buttonClicked.equals("sdm")) {
            userType = "sdm";
        }
    }


    usernameEditText = (EditText) findViewById(R.id.username);
    inputPassword = (EditText) findViewById(R.id.password);
    btnLogin = (Button) findViewById(R.id.login);
    btnLinkToRegister = (Button) findViewById(R.id.register);

    // Progress dialog
    pDialog = new ProgressDialog(this);
    pDialog.setCancelable(false);

}


public void loginCLick(View view) throws SocketException {
    Log.i(TAG, "entered login");
    String username = usernameEditText.getText().toString().trim();
    String ashaphno = username;
    String password = inputPassword.getText().toString().trim();
    // Check for empty data in the form
    if (!ashaphno.isEmpty() && !password.isEmpty()) {
        chkStatus();
        // login user
        checkLogin(ashaphno, password);

        Log.i(TAG, "username(ashaphone)" + username);

        Intent i;

    }
}


// Link to Register Screen
public void clickregister(View view) {


    Intent i = new Intent(getApplicationContext(),
            AshaRegisterActivity.class);
    startActivity(i);
    finish();
}


/**
 * function to verify login details in mysql db
 */
public void checkLogin(final String ashaphno, final String password) {
    // Tag used to cancel the request
    String tag_string_req = "req_login";

    pDialog.setMessage("Logging in ...");
    pDialog.show();

    StringRequest strReq = new StringRequest(Request.Method.POST,
            Constants.URL_LOGIN, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Log.d(TAG, "Login Response: " + response.toString());
            pDialog.dismiss();

            try {
                JSONObject jsonObject = new JSONObject(response.substring(response.indexOf("{"), response.lastIndexOf("}") + 1));
                boolean error = jsonObject.getBoolean("error");

                // Check for error node in json
                if (!error) {
                    // user successfully logged in
                    // Create login session
                    Log.i(TAG, "loginactivity" + userType);
                    if (userType.equals("asha")) {
                        JSONObject asha = jsonObject.getJSONObject("asha");
                        String username = asha.getString("AshaUsername");
                        String phone = asha.getString("Ashaphno");

                        if (username.equals(phone)) {
                            // Launch main activity
                            Intent intent = new Intent(LoginActivitywithConnection.this,
                                    LoginOpeningPageAsha.class);
                            Bundle b = new Bundle();
                            b.putString("username", ashaphno);
                            intent.putExtras(b);
                            startActivity(intent);
                            finish();
                        }

                    } else if
                    (userType.equals("anm")) {
                        Intent i;
                        i = new Intent(LoginActivitywithConnection.this, LoginOpeningPageANM.class);
                        Bundle b = new Bundle();

                        b.putString("username", ashaphno);
                        i.putExtras(b);

                        startActivity(i);
                    }

                } else {
                    // Error in login. Get the error message
                    String errorMsg = jsonObject.getString("message");
                    Toast.makeText(getApplicationContext(),
                            errorMsg, Toast.LENGTH_LONG).show();
                    Log.i(TAG, "error" +
                            errorMsg);
                }
            } catch (JSONException e) {
                // JSON error
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
            }

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            Log.e(TAG, "Login Error: " + volleyError.getMessage());

            String message = null;
            if (volleyError instanceof NetworkError) {
                message = "Cannot connect to Internet...Please check your connection!";
            } else if (volleyError instanceof ServerError) {
                message = "The server could not be found. Please try again after some time!!";
            } else if (volleyError instanceof AuthFailureError) {
                message = "Cannot connect to Internet...Please check your connection!";
            } else if (volleyError instanceof ParseError) {
                message = "Parsing error! Please try again after some time!!";
            } else if (volleyError instanceof NoConnectionError) {
                message = "Cannot connect to Internet...Please check your connection!";
            } else if (volleyError instanceof TimeoutError) {
                message = "Connection TimeOut! Please check your internet connection.";
            }
            Toast.makeText(getApplicationContext(),
                    message, Toast.LENGTH_LONG).show();
            String erroridentifier = handleServerError(volleyError, getApplicationContext());
            Log.e(TAG, "Login Erroridentifier: " + erroridentifier);
            hideDialog();
        }
    }) {

        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<String, String>();
            params.put("AshaUsername", ashaphno);
            params.put("ASHApwd", password);

            return params;
        }

    };

    DefaultRetryPolicy retryPolicy = new DefaultRetryPolicy(0, -1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    strReq.setRetryPolicy(retryPolicy);


    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}

当用户下载此apk时,服务器URL是什么(不是本地的)?

我将是同一个URL服务器,如果您想让apk在任何地方运行,您应该创建一个公共服务器。Azure、Google等,或具有公共IP的服务器。

我将是同一个URL服务器,如果你想让apk在任何地方运行,你应该创建一个公共服务器。Azure、Google等,或具有公共IP的服务器。

我假设您正在使用某个本地主机并提供PHP代码来实现身份验证,在将android应用程序发布到GooglePlay等商店之前,您应该首先将后端代码部署到Azure、Digital ocean等服务器中,。。。在某些服务器上部署并运行后端代码后,您应该在应用程序中输入后端的URL。此外,我建议你使用你的人际关系的东西,这将减少很多东西,你应该处理

我假设您正在使用某个本地主机并提供PHP代码来实现身份验证,在将android应用程序发布到GooglePlay等商店之前,您应该首先将后端代码部署到Azure、Digital ocean等服务器上,。。。在某些服务器上部署并运行后端代码后,您应该在应用程序中输入后端的URL。此外,我建议你使用你的人际关系的东西,这将减少很多东西,你应该处理

非常感谢。将研究改装。非常感谢。将研究改装
    public class Constants {

    private static final String ROOT_URL ="http://192.168.43.6/Android/v1/";
    // Server user login url
    public static String URL_LOGIN = ROOT_URL+"ashaLogin.php";


}