该应用经核实,在首次下载/登录app页面(进入应用第一个界面)未发现用户协议和隐私政策提示,根据安管部门需求,需应用内容需包含以上二点。

private void initFirst() {
        if (SpUtils.getBoolean("isFirst", false)) {
            return;
        }



        TextView tv1 = new TextView(this);
        tv1.setText(getResources().getString(R.string.user_agreement));
        tv1.setTextSize(14);
        tv1.setTextColor(Color.BLUE);
        tv1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               '''
            }
        });

        TextView tv2 = new TextView(this);
        tv2.setText(getResources().getString(R.string.privacy_policy));
        tv2.setTextSize(14);
        tv2.setTextColor(Color.BLUE);
        tv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                 '''
            }
        });

        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setGravity(Gravity.CENTER);
        linearLayout.addView(tv1);
        linearLayout.addView(tv2);
        setMargins(tv1,50, 20, 0, 0);
        setMargins(tv2,50, 20, 0, 0);


        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setView(linearLayout);
        builder.setMessage("为了您更好的用户体验,请阅读并同意以下条款");
        builder.setCancelable(false);
        builder.setPositiveButton(R.string.readok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                SpUtils.putBoolean("isFirst", true);
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(R.string.later, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
            }
        });
        builder.show();


    }
  public static void setMargins (View v, int l, int t, int r, int b) {
        if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
            p.setMargins(l, t, r, b);
            v.requestLayout();
        }
    }

 

你可能感兴趣的:(002android)