Intent 跳转发短信、打电话、到设置界面等

来源:互联网 发布:java flag标志位 编辑:程序博客网 时间:2024/06/06 16:37

此篇博文是整理网上前辈写的,非自写


1、直接拨打电话

  1. Intent intentPhone = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
    startActivity(intentPhone);


2、跳到拨号界面

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


3、调用系统打发短信的界面
Uri smsToUri = Uri.parse("smsto:" + phone);
Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);
intent.putExtra("sms_body", message);
context.startActivity(intent);

4、跳转到联系人界面
Intent intentPhone = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
startActivity(intentPhone);

5、安装忆存在apk

 String filePath="mnt/sdcard/abc.apk";
Intent intent = new  Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + filePath),"application/vnd.android.package-archive");
startActivity(intent);//直接跳到安装页面,但是还要点击按钮确定安装,还是取消安装


6、卸载某apk

String packageName="org.adw.launcher2"
Uri packageUri = Uri.parse("package:"+packageName);//包名,指定该应用
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
startActivity(uninstallIntent);


7浏览某具体网址

Uri uri = Uri.parse("http://xxxxxxxxxxxxxxxxxxxxxxxx");  
 Intent intent   = new Intent(Intent.ACTION_VIEW,uri);
//加下面这句话就是启动系统自带的浏览器打开上面的网址,  不加下面一句话,  如果你有多个浏览器,就会弹出让你选择某一浏览器, 然后改浏览器就会打开该网址...............
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); 
 startActivity(intent);


8、系统设置界面

Intent intent=new Intent();
intent.setClassName("com.android.settings","com.android.settings.Settings");
startActivity(intent); 


0 0
原创粉丝点击