隐式调用 Intent 大全, 很全

//调用浏览器



收藏代码
01.Uri uri = Uri.parse(""); 
02.Intent it  = new Intent(Intent.ACTION_VIEW,uri); 
03.startActivity(it); 



//显示某个坐标在地图上



收藏代码
01.Uri uri = Uri.parse("geo:38.899533,-77.036476"); 
02.Intent it = new Intent(Intent.Action_VIEW,uri); 
03.startActivity(it);  



//显示路径



收藏代码
01.Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en"); 
02.Intent it = new Intent(Intent.ACTION_VIEW,URI); 
03.startActivity(it); 



//拨打电话



收藏代码
01.Uri uri = Uri.parse("tel:10086"); 
02.Intent it = new Intent(Intent.ACTION_DIAL, uri);   
03.startActivity(it);  
04. 
05.Uri uri = Uri.parse("tel.10086"); 
06.Intent it =new Intent(Intent.ACTION_CALL,uri); 
07.需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 这个权限到androidmanifest.xml 



//发送短信或彩信



收藏代码
01.Intent it = new Intent(Intent.ACTION_VIEW);    
02.it.putExtra("sms_body", "The SMS text");    
03.it.setType("vnd.android-dir/mms-sms");    
04.startActivity(it);   



//发送短信



收藏代码
01.Uri uri = Uri.parse("smsto:10086");    
02.Intent it = new Intent(Intent.ACTION_SENDTO, uri);    
03.it.putExtra("sms_body", "cwj");    
04.startActivity(it);   



//发送彩信



收藏代码
01.Uri uri = Uri.parse("content://media/external/images/media/23");    
02.Intent it = new Intent(Intent.ACTION_SEND);    
03.it.putExtra("sms_body", "some text");    
04.it.putExtra(Intent.EXTRA_STREAM, uri);    
05.it.setType("image/png");    
06.startActivity(it);  



//发送邮件



收藏代码
01.  
02.Uri uri = Uri.parse("mailto:[email protected]"); 
03.Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
04.startActivity(it); 
05. 
06.Intent it = new Intent(Intent.ACTION_SEND);    
07.it.putExtra(Intent.EXTRA_EMAIL, [email protected]);    
08.it.putExtra(Intent.EXTRA_TEXT, "The email body text");    
09.it.setType("text/plain");    
10.startActivity(Intent.createChooser(it, "Choose Email Client"));   
11. 
12.Intent it=new Intent(Intent.ACTION_SEND);      
13.String[] tos={"[email protected]"};      
14.String[] ccs={"[email protected]"};      
15.it.putExtra(Intent.EXTRA_EMAIL, tos);      
16.it.putExtra(Intent.EXTRA_CC, ccs);      
17.it.putExtra(Intent.EXTRA_TEXT, "The email body text");      
18.it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");      
19.it.setType("message/rfc822");      
20.startActivity(Intent.createChooser(it, "Choose Email Client"));    



//播放媒体文件



收藏代码
01.Intent it = new Intent(Intent.ACTION_VIEW); 
02.Uri uri = Uri.parse("file:///sdcard/cwj.mp3"); 
03.it.setDataAndType(uri, "audio/mp3"); 
04.startActivity(it); 
05. 
06.Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");    
07.Intent it = new Intent(Intent.ACTION_VIEW, uri);    
08.startActivity(it);   



//卸载APK



收藏代码
01.Uri uri = Uri.fromParts("package", strPackageName, null);    
02.Intent it = new Intent(Intent.ACTION_DELETE, uri);    
03.startActivity(it); 



//卸载apk 2



收藏代码
01.Uri uninstallUri = Uri.fromParts("package", "xxx", null); 
02.returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri); 



//安装APK



收藏代码
01.Uri installUri = Uri.fromParts("package", "xxx", null); 
02.returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 

//使用系统相机



收藏代码
01.Intent intent = new Intent("android.media.action,IMAGE_CAPTURE");
02.startActivity(intent); 




//播放音乐



收藏代码
01.Uri playUri = Uri.parse("file:///sdcard/download/sth.mp3"); 
02.returnIt = new Intent(Intent.ACTION_VIEW, playUri); 



//发送附近



收藏代码
01.Intent it = new Intent(Intent.ACTION_SEND);   
02.it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   
03.it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/cwj.mp3");   
04.sendIntent.setType("audio/mp3");   
05.startActivity(Intent.createChooser(it, "Choose Email Client")); 



//market上某个应用信,pkg_name就是应用的packageName



收藏代码
01.Uri uri = Uri.parse("market://search?q=pname:pkg_name");   
02.Intent it = new Intent(Intent.ACTION_VIEW, uri);   
03.startActivity(it);   



//market上某个应用信息,app_id可以通过www网站看下



收藏代码
01.Uri uri = Uri.parse("market://details?id=app_id");   
02.Intent it = new Intent(Intent.ACTION_VIEW, uri);   
03.startActivity(it);   


猜你喜欢

转载自1392289478.iteye.com/blog/2105727