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());
}
}
}