Android how to hide or protect url link in source code

I used the url link in my application to send and receive data from the server. If some body decompiles my apk file and the source can use the URL and send spam or make purchases without payment!

now how can i protect urls?

This is an example of a server request that I used. (so far I am using the local server until the application is completed)

public class GetProduct {

    ArrayList<Product> arrayList;
    ProgressDialog progressDialog;
    String url = "http://192.168.43.46/fasabazar/android/getProductsFullInfo";
    OnProductRecieved onProductRecieved = null;

    public GetProduct(final OnProductRecieved onProductRecieved, final Context context) {
        arrayList = new ArrayList<>();
        progressDialog = new ProgressDialog(context);
        this.onProductRecieved = onProductRecieved;
        JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {

                JSONArray jsonArray = (JSONArray) response;
                progressDialog.dismiss();
                onProductRecieved.OnRecieved(response);
                // Toast.makeText(context, jsonArray.toString(), Toast.LENGTH_SHORT).show();

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });

        progressDialog.show();
        request.setRetryPolicy(new DefaultRetryPolicy(7000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        RequestQueue requestQueue = Volley.newRequestQueue(context);
        requestQueue.add(request);
    }

    public interface OnProductRecieved {
        void OnRecieved(JSONArray response);
    }
}
+4
source share
1 answer

You cannot reliably protect these URLs. You can confuse your code, but there are tools to undo obfuscation.

- , , , - . ; -, , .

  • HTTPS, "" URL. "" . .
  • HTTPS, . , URL-. HTTPS , URL , , URL- , - HTTPS, .
  • -, -, - ( ) ( ). -.

, , .

0

Source: https://habr.com/ru/post/1693370/


All Articles