日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

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

發布時間:2023/12/10 Android 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android 起调系统功能,打开系统浏览器,拨打电话,发送短信,手机震动,跳转到设置通知开关页面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?1、打開系統瀏覽器

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

?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、發送短信

//發送短信 private void sendSMSS() {Log.e("lgqq","....fa");String content = nret.getText().toString().trim();//短信內容String phone = telet.getText().toString().trim();//電話號碼if (!content.isEmpty() && !phone.isEmpty()) {SmsManager manager = SmsManager.getDefault();ArrayList<String> strings = manager.divideMessage(content);for (int i = 0; i < strings.size(); i++) {manager.sendTextMessage(phone, null, content, null, null);}Toast.makeText(DiweiActivity.this, "發送成功", Toast.LENGTH_SHORT).show();} else {Toast.makeText(this, "手機號或內容不能為空", Toast.LENGTH_SHORT).show();return;} } private static final int SEND_SMS = 100;private void requestPermission() {//判斷Android版本是否大于23if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {int checkCallPhonePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS);if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) {ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, SEND_SMS);Log.e("lgqq","...222.fa=="+checkCallPhonePermission);return;} else {Log.e("lgqq","..222244444..fa");sendSMSS();//已有權限}} else {//API 版本在23以下sendSMSS();} }

?

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

?

預覽淘寶

public void toshop(String tbPath){Intent intent = new Intent();intent.setAction("Android.intent.action.VIEW");Uri uri = Uri.parse(tbPath); // 商品地址intent.setData(uri);//詳情頁 // intent.setClassName("com.taobao.taobao", "com.taobao.tao.detail.activity.DetailActivity");//店鋪intent.setClassName("com.taobao.taobao", "com.taobao.android.shop.activity.ShopHomePageActivity");startActivity(intent);}

判斷通知開啟,跳轉到通知設置系統頁面

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

?

?

總結

以上是生活随笔為你收集整理的Android 起调系统功能,打开系统浏览器,拨打电话,发送短信,手机震动,跳转到设置通知开关页面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。