3

この要件と手順に従って安全なアプリを使用するという Android の新しいポリシーに Android アプリを準拠させようとしています。

1) 最初にアプリの URL に SSL と https を追加しました 2) 次に、HttpURLConnection の代わりにクラス HttpsURLConnection の使用を開始しました

私が使用するリモート呼び出しの例を次に示します。

   public void sendFeedback(String name , String email , String password ) 
   {  
        String[] params = new String[] { "https://www.problemio.com/auth/create_profile_mobile.php", name , email , password };

        DownloadWebPageTask task = new DownloadWebPageTask();
        task.execute(params);        
   }

   public class DownloadWebPageTask extends AsyncTask<String, Void, String> 
   {       
        private boolean connectionError = false;


     @Override
     protected void onPreExecute( ) 
     {
          dialog = new Dialog(CreateProfileActivity.this);

          dialog.setContentView(R.layout.please_wait);
          dialog.setTitle("Creating Profile");

          TextView text = (TextView) dialog.findViewById(R.id.please_wait_text);
          text.setText("Please wait while your profile is created... ");
          dialog.show();
     }             

    @Override
    protected String doInBackground(String... theParams) 
    {
        String myUrl = theParams[0];
        final String name = theParams[1];
        final String email = theParams[2];
        final String password = theParams[3];

        String charset = "UTF-8";                       
        String response = null;

        try 
        {               
            String query = String.format("name=%s&email=%s&password=%s", 
                     URLEncoder.encode(name, charset), 
                     URLEncoder.encode(email, charset), 
                     URLEncoder.encode(password, charset));

            final URL url = new URL( myUrl + "?" + query );

            final HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();

            conn.setDoOutput(true); 
            conn.setRequestMethod("POST");

            conn.setDoOutput(true);

            conn.setUseCaches(false);

            conn.connect();

            final InputStream is = conn.getInputStream();
            final byte[] buffer = new byte[8196];
            int readCount;
            final StringBuilder builder = new StringBuilder();
            while ((readCount = is.read(buffer)) > -1) 
            {
                builder.append(new String(buffer, 0, readCount));
            }

            response = builder.toString();      
        } 
        catch (Exception e) 
        {
              connectionError = true;
        }

        return response;
    }

    @Override
    protected void onPostExecute(String result) 
    {       
        // Some code

            // Make an intent to go to the home screen
            Intent myIntent = new Intent(CreateProfileActivity.this, MainActivity.class);
            CreateProfileActivity.this.startActivity(myIntent);
        }
    }    
}

しかし、開発者コンソールの警告サインは削除されませんでした。私が間違っていることと、これを修正する方法はありますか?

4

1 に答える 1