调用系统功能,邮件发送方式,各种文件打开方法-Intent的详解

来源:互联网 发布:县医院 网络图片图 编辑:程序博客网 时间:2024/05/16 01:21

Android打开各种类型的文件方法总结- http://blog.csdn.net/eclipsexys/article/details/39552501

android调用系统功能-- http://blog.csdn.net/d945332077/article/details/8116326
android平台收发邮件-- http://blog.csdn.net/elena_wang/article/details/12648581

> 打开Android手机安装的邮件客户端,可选择

Uri uri = Uri.parse("mailto:test@test.com");

Intent intent = new Intent(Intent.ACTION_SENDTO,uri);

startActivity(Intent.createChooser(intent, "选择邮件客户端"));

-------------------

> 邮件发送方式,其他文件打开方式-Intent的使用

android邮件发送几种方式--http://wcf1987.iteye.com/blog/1292509
Android邮件发送详解--http://blog.csdn.net/xanxus46/article/details/8296598/
【Android】发送Email(内置Gmail和JavaMail)--http://blog.csdn.net/lizhenmingdirk/article/details/7474918
android intent和intent action大全-- http://www.cnblogs.com/playing/archive/2010/09/15/1826918.html
Android开发之Intent.Action--http://www.cnblogs.com/hanyonglu/archive/2012/03/26/2417278.html
Android之调用系统Email发送邮件-- http://blog.csdn.net/way_ping_li/article/details/9038655
Android之Intent全面解析及用法--http://blog.csdn.net/cndrip/article/details/7191072
android上的默认Intent -- http://blog.csdn.net/xiaodanpeng/article/details/8282947
android intent打开各种文件的方法-- http://blog.csdn.net/wangyang2698341/article/details/20847469
Android 用Intent调用系统中经常被用到的组件-- http://www.cnblogs.com/zyw-205520/archive/2013/02/03/2890936.html
Android开发调用第三方邮件应用发送邮件-- http://blog.csdn.net/wangshihui512/article/details/51332744

转自美团技术博客的jvm内存泄露分析:http://blog.csdn.net/king_is_everyone/article/details/41984295
----------------------------
> 通过Intent ACTION_SEND方法发送邮件,弹出的客户端选择
Java code
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"test@test.com"});
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT");
intent.putExtra(android.content.Intent.EXTRA_TEXT, "TEXT");
intent.setType("text/html");
startActivity(Intent.createChooser(intent, "Chooser"));

在出现的客户端选择中,只有Gmail和蓝牙,没有默认的Email客户端,这是为什么呢?
ACTION_SEND 这个方式就是用Gmail发送,而且不能指定用别的邮箱发送...
android发送邮件有两种方式,
一种就是你用的方法,用gmail,直接用intent来实现
另一种是用java的方式发送邮件,要设置pop,账户,密码等。。。

> 从浏览器跳转到app客户端
现在,用的方法是Response.Redirect("taobao://");(例如跳转到淘宝的客户端),在ios系统的浏览器上可以跳转到淘宝的客户端。但是在安卓系统的浏览器上,只是在当前浏览器上打开了淘宝客户端,而不是跳转到淘宝客户端。请问各位大神,该怎么解决呢?
------解决思路----------------------
java 与javaScript调用
------解决思路----------------------
Android提供了字符串形式的intent来解决这个问题,可以参考这篇文章。http://droidyue.com/blog/2014/11/23/start-android-application-when-click-a-link/
------解决思路----------------------
http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser

-------------------------------------------------------------------

> 打开默认浏览器

Intent intent =newIntent();        
         intent.setAction("android.intent.action.VIEW");    
         Uri content_url =Uri.parse("http://www.163.com");   
         intent.setData(content_url);           
         intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");   
         startActivity(intent);
只要修改以intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
中相应的应用程序packagename 和要启动的activity即可启动其他浏览器来
uc浏览器":"com.uc.browser", "com.uc.browser.ActivityUpdate“
opera浏览器:"com.opera.mini.android", "com.opera.mini.android.Browser"
qq浏览器:"com.tencent.mtt", "com.tencent.mtt.MainActivity"

1. Intent open a picture file public:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new
File("/mnt/sdcard/images/001041580.jpg"));
intent.setDataAndType (uri, "image/*");
this.startActivity(intent);
 
2. Intent to open a PDF file:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new
File("file:///android_asset/helphelp.pdf"));
intent.setDataAndType (uri, "application/pdf");
this.startActivity(intent);
 
3. Intent to open a text file:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
if (paramBoolean)
{
Uri uri1 = Uri.parse (param);
intent.setDataAndType (URI1, "text/plain");
}
else
{
Uri uri = Uri.fromFile(new File("/mnt/sdcard/hello.txt"));
intent.setDataAndType (URI2, "text/plain");
}
this.startActivity(intent);
 
4. Intent to open the audio file:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra ("oneshot",0);
intent.putExtra ("configchange",0);
Uri uri = Uri.fromFile(new File("/mnt/sdcard/ren.mp3"));
intent.setDataAndType (uri, "audio/*");
this.startActivity(intent);


5. Intent to open the video file:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra ("oneshot",0);
intent.putExtra ("configchange",0);
Uri uri = Uri.fromFile(new File("/mnt/sdcard/ice.avi"));
intent.setDataAndType (uri, "video/*");
this.startActivity(intent);
 
6. Intent to open the CHM file:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File("/mnt/sdcard/ice.chm"));
intent.setDataAndType (uri, "application / x-chm");
this.startActivity(intent);
 
7. Intent to open a Word document:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File("/system/etc/help.doc"));
intent.setDataAndType(uri, "application/msword");
this.startActivity(intent);
 
8. Android Excel intent:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File("/mnt/sdcard/Book1.xls"));
intent.setDataAndType (uri, "application/vnd.ms-excel");
this.startActivity(intent);
 
9. Intent to open the PPT file:
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new
File("/mnt/sdcard/download/Android_PPT.ppt"));
intent.setDataAndType (uri, "application/vnd.ms-powerpoint");
this.startActivity(intent);
 
10. Display Html page::
Uri uri = Uri.parse ("http://www.google.com");
Intent intent = new Intent (Intent.ACTION_VIEW, uri);
this.startActivity(intent);
 
11. Show map:
Uri uri = Uri.parse ("geo: 38.899533, -77.036476");
Intent intent = new Intent (Intent.Action_VIEW, uri);
this.startActivity(intent);
 
12. Call the dialer:
Uri uri = Uri.parse ("tel: xxxxxx");
Intent intent = new Intent (Intent.ACTION_DIAL, uri);
this.startActivity(intent);
 
13. Call :
Uri uri = Uri.parse ("tel: xxxxxx");
Intent it = new Intent (Intent.ACTION_CALL, uri);
this.startActivity(intent);
/*permission:
<uses-permission id="android.permission.CALL_PHONE">
</uses-permission> */
 
14. Call to send text messages of the program :
Intent intent = new Intent (Intent.ACTION_VIEW);
intent.putExtra("sms_body","The SMS text");
intent.setType("vnd.android-dir/mms-sms");
this.startActivity(intent);
 
15. Send SMS :
Uri uri = Uri.parse("smsto:0800000123");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body","The SMS text");
this.startActivity(intent);
 
16. Send MMS :
Uri uri = Uri.parse("content://media/external/images/media/23");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body","some text");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
this.startActivity(intent);
 
17. Send an Email :
Uri uri = Uri.parse ("mailto: xxx@abc.com");
Intent intent = new Intent (Intent.ACTION_SENDTO, uri);
this.startActivity(intent);
 
18. Send an Email with body :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL,"me@abc.com");
intent.putExtra(Intent.EXTRA_TEXT,"The email body text");
intent.setType ("text/plain");
this.startActivity(
Intent.createChooser(intent, "Choose Email Client"));
 
19. Send an Email with body,to,cc :
Intent intent = new Intent(Intent.ACTION_SEND);
String [] tos ={"me@abc.com"};
String [] ccs ={"you@abc.com"};
intent.putExtra(Intent.EXTRA_EMAIL, tos);
intent.putExtra(Intent.EXTRA_CC, ccs);
intent.putExtra(Intent.EXTRA_TEXT, "The email body text");
intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
intent.setType("message/rfc822");
this.startActivity(
Intent.createChooser(intent, "Choose Email Client"));
 
20. Send an Email with attachments :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT,"The email subject text");
intent.putExtra(Intent.EXTRA_STREAM,"file :///sdcard/mysong.mp3");
sendIntent.setType("audio/mp3");
this.startActivity(
Intent.createChooser(intent,"Choose Email Client"));
 
21. Uninstall the program :
Uri uri = Uri.fromParts ("package", strPackageName,null);
Intent intent = new Intent (Intent.ACTION_DELETE, uri);
this.startActivity(
Intent.createChooser(intent,"Choose Email Client"));
 
22. Install the apk :
Uri installUri = Uri.fromParts("package","xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
this.startActivity(returnIt);
 
23. Search applications :
Uri uri = Uri.parse("market://search?Q=pname:pkg_name");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
this.startActivity(intent);
//Where pkg_name is the full package path for an application
 
24. Google Search Launch Web Browser :
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String term = "Android";
intent.putExtra(SearchManager.QUERY, term);
activity.startActivity(intent);
 
25. Send text using Intent (to messaging apps) :
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String msgBody = "This is message";
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"message subject");
intent.putExtra(android.content.Intent.EXTRA_TEXT, msgBody);
activity.startActivity(Intent.createChooser(intent, getResources().
getString(R.string.share_by_using)));
 
26. Create Shortcut on "Home Screen" :
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
Intent toPrint = new Intent(this, anCreateshutcut.class);
Intent addShortcut = new Intent
("com.android.launcher.action.INSTALL_SHORTCUT");
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Shutcutname");
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, toPrint);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
Manifest file:
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT">
<category android:name="android.intent.category.LAUNCHER">
</category></action></intent-filter>
<uses-permission android:name="com.android.launcher.
permission.INSTALL_SHORTCUT">
</uses-permission>

27. 18身份证号码校验

18身份证号码的结构-公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位校验码。
(1)十七位数字本体码加权求和公式
  S = Sum(Ai * Wi), i = 0, … , 16 ,先对前17位数字的权求和
  Ai:表示第i位置上的身份证号码数字值(0~9)
  Wi:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 (表示第i位置上的加权因子)
(2)计算模   Y = mod(S, 11)
(3)根据模,查找得到对应的校验码   Y: 0 1 2 3 4 5 6 7 8 9 10   校验码: 1 0 X 9 8 7 6 5 4 3 2

根据17位数字本体码获取最后一位校验码程序实例
public class Id18 {
    int[] weight={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};    //十七位数字本体码权重
    char[] validate={ '1','0','X','9','8','7','6','5','4','3','2'};    //mod11,对应校验码字符值    
    
    public char getValidateCode(String id17){
        int sum = 0;
        int mode = 0;
        for(int i = 0; i < id17.length(); i++){
            sum=sum+Integer.parseInt(String.valueOf(id17.charAt(i)))*weight[i];
        }
        mode = sum % 11;
        return validate[mode];
    }
    
    public static void main(String[] args){
        Id18 tes t= new Id18();
        System.out.println("该身份证验证码:"+test.getValidateCode("14230219700101101"));    //该身份证校验码:3
    }
}

1 0
原创粉丝点击