拨打电话-吊起拨打界面且拨打
Uri uri = Uri.parse("tel:10086");
Intent intent = new Intent(Intent.ACTION_CALL, uri);
startActivity(intent);
跳转到相册
Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 请求码);
Uri uri = data.getData();
// 通过uri的方式返回,设置到图片组件上
Uri uri = data.getData();
iv_head.setImageURI(uri);
SharedPreferences的查询和获取数据
//获取数据
SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
String key = user.getString("key", "");
SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
// 保存数据
user.edit().putString("key","hello world!").commit();
倒计时
// 计时器,5秒每间隔一秒执行一次
new CountDownTimer(5000,1000){
@Override
public void onTick(long millisUntilFinished) {
Log.d(TAG, "onTick: "+millisUntilFinished);
}
@Override
public void onFinish() {
Log.d(TAG, "onFinish: 执行结束");
}
}.start();
网友评论