Android Intent 页面跳转封装 Base64两次加密解密 放入如何一个项目都可以使用 XXX is translated here but not found in def

 Intent路由跳转,简单的封装一下,暂时不能传递参数,后续会更新

    //packageContext--当前Activity
    //cls--需要跳转的Activity
    //activity--需要关闭的页面的Activity
    public static void JumpPageFinish(Context packageContext, Class<?> cls, Activity activity) {
        packageContext.startActivity(new Intent(packageContext, cls).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        activity.finish();
    }

    public static void JumpPage(Context packageContext, Class<?> cls) {
        packageContext.startActivity(new Intent(packageContext, cls).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    }

 Base64的加密和解密

public static final String encode(String data) {
        if (TextUtils.isEmpty(data)) return null;
        return Base64.encodeToString(Base64.encode(data.getBytes(), Base64.NO_WRAP), Base64.NO_WRAP);
    }

    public static final String decode(String data) {
        try {
            if (TextUtils.isEmpty(data)) return null;
            return new String(Base64.decode(Base64.decode(data.getBytes(), Base64.NO_WRAP), Base64.NO_WRAP));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
    }

 AlertDialog-弹窗样式比较简单

private void AlertDialog() {
//        Dialog dialog=new Dialog(this);
//        dialog.setContentView(R.layout.item_text);
//        dialog.show();
//            title.setText(getString(R.string.app_name));
//            title.setTextSize(24);
//            title.setTextColor(Color.BLUE);
        AlertDialog.Builder builder = new AlertDialog.Builder(GameCenterActivity.this);
        //图标
        builder.setIcon(R.mipmap.ic_launcher);
        //标题
        builder.setTitle(getString(R.string.app_name));
        //提示
        builder.setMessage("Welcome to here");
//        TextView title =findViewById(android.R.id.message);
//        title.setTextSize(24);
        //按钮
        builder.setPositiveButton("OK", null);
//        builder.setNegativeButton("取消", null);
//        builder.setNeutralButton("中性按钮", null);
        builder.setCancelable(true);
        AlertDialog dialog = builder.create();
//        dialog.setCustomTitle(title);
        dialog.show();
//        WindowManager.LayoutParams params =
//                dialog.getWindow().getAttributes();
//        params.width = 200;
//        params.height = 200 ;
        TextView textView = (TextView) dialog.findViewById(android.R.id.message);
        textView.setTextSize(40);
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextSize(20);
//        dialog.getWindow().setLayout(700, 520);
    }

出现这样的报错 XXX is translated here but not found in default locale--build.gradle中的Android里面加下面的代码

    lintOptions { disable 'MissingTranslation', 'ExtraTranslation' }

 随机生成变量名

public class text {
    public static void main(String[] args) {
        List<Character> str = new ArrayList<>();
        char a = 'a';
        StringBuilder stringBuilder = new StringBuilder("");
        str.clear();
        for (int i = 0; i < 26; i++) {
            str.add((char) (a + i));
        }
        for (int j = 0; j < 70; j++) {
            for (int i = 0; i < 12; i++) {
                Random random = new Random();
                int i1 = random.nextInt(25);
                char c = str.get(i1);
                if (j > 50) {
                    c=Character.toUpperCase(c);
                }
                stringBuilder.append(c);
            }
            System.out.println(stringBuilder);
            stringBuilder.delete(0, stringBuilder.length());
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

《King》-Flutter开发工程师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值