当前位置:   article > 正文

Android 起调系统功能,打开系统浏览器,拨打电话,发送短信,手机震动,跳转到设置通知开关页面_android浏览器打开短信发送

android浏览器打开短信发送

 1、打开系统浏览器

  1. try {
  2. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jaredrummler/MaterialSpinner")));
  3. } catch (ActivityNotFoundException ignored) {
  4. }

 2、拨打电话

Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+phone));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
 

        Intent intent=new Intent();
        //设置打电话行为
//        intent.setAction(Intent.ACTION_CALL);
        intent.setAction(Intent.ACTION_DIAL);
        //设置数据,此处为电话号码
//        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse("tel:12345678901"));
        startActivity(intent);

 

3、发送短信

  1. //发送短信
  2. private void sendSMSS() {
  3. Log.e("lgqq","....fa");
  4. String content = nret.getText().toString().trim();//短信内容
  5. String phone = telet.getText().toString().trim();//电话号码
  6. if (!content.isEmpty() && !phone.isEmpty()) {
  7. SmsManager manager = SmsManager.getDefault();
  8. ArrayList<String> strings = manager.divideMessage(content);
  9. for (int i = 0; i < strings.size(); i++) {
  10. manager.sendTextMessage(phone, null, content, null, null);
  11. }
  12. Toast.makeText(DiweiActivity.this, "发送成功", Toast.LENGTH_SHORT).show();
  13. } else {
  14. Toast.makeText(this, "手机号或内容不能为空", Toast.LENGTH_SHORT).show();
  15. return;
  16. }
  17. }
  1. private static final int SEND_SMS = 100;
  2. private void requestPermission() {
  3. //判断Android版本是否大于23
  4. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  5. int checkCallPhonePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS);
  6. if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) {
  7. ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, SEND_SMS);
  8. Log.e("lgqq","...222.fa=="+checkCallPhonePermission);
  9. return;
  10. } else {
  11. Log.e("lgqq","..222244444..fa");
  12. sendSMSS();
  13. //已有权限
  14. }
  15. } else {
  16. //API 版本在23以下
  17. sendSMSS();
  18. }
  19. }

 

4、Vibrator手机震动

 

1、权限

<uses-permission android:name="android.permission.VIBRATE"/>
2、初始化

private Vibrator vibrator;
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
3、开始震动

(1)一次性震动
vibrator.vibrate(10);//10震动时长
(2)波浪性震动
开启

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    vibrator.vibrate(VibrationEffect.createWaveform(new long[]{100L, 2000L, 1000L, 1000L, 3000L}, -1));
} else {
    vibrator.vibrate(new long[]{100L, 2000L, 1000L, 1000L, 3000L}, 0);
}
关闭

vibrator.cancel();

 

预览淘宝

  1. public void toshop(String tbPath){
  2. Intent intent = new Intent();
  3. intent.setAction("Android.intent.action.VIEW");
  4. Uri uri = Uri.parse(tbPath); // 商品地址
  5. intent.setData(uri);
  6. //详情页
  7. // intent.setClassName("com.taobao.taobao", "com.taobao.tao.detail.activity.DetailActivity");
  8. //店铺
  9. intent.setClassName("com.taobao.taobao", "com.taobao.android.shop.activity.ShopHomePageActivity");
  10. startActivity(intent);
  11. }

判断通知开启,跳转到通知设置系统页面

  1. NotificationManagerCompat manager = NotificationManagerCompat.from(App.getTotalContext());
  2. boolean isOpened = manager.areNotificationsEnabled();
  1. if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  2. Intent intent = new Intent();
  3. intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
  4. intent.putExtra("app_package", getActivity().getPackageName());
  5. intent.putExtra("app_uid", getActivity().getApplicationInfo().uid);
  6. startActivity(intent);
  7. } else if (android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
  8. Intent intent = new Intent();
  9. intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  10. intent.addCategory(Intent.CATEGORY_DEFAULT);
  11. intent.setData(Uri.parse("package:" + getActivity().getPackageName()));
  12. startActivity(intent);
  13. }

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/97183?site
推荐阅读
相关标签
  

闽ICP备14008679号