首页 > 其他 > 详细

Intent 、Intent Filter 和传输数据

时间:2014-12-11 13:47:53      阅读:295      评论:0      收藏:0      [点我收藏+]

Intent  使用

 

最常使用的是:

Intent intent = new Intent();
intent.setClass(Main.this,New.class);
startActivity(intent);

其他的Intent 的使用:

打开一个网站:

Uri uri = Uri.parse("http://www.shike.im/");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);

打开一个音乐

Intent it = new Intent(Intent.ACTION_VIEW);
File file = new File("/sdcard/song.mp3");
it.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(it);

 

打开一个图片:

Intent it = new Intent(Intent.ACTION_VIEW);
File file = new File("/sdcard/image.png");
it.setDataAndType(Uri.fromFile(file), "image/*");
startActivity(it);

 

Intent 、Intent Filter 和传输数据

原文:http://www.cnblogs.com/zhoujn/p/4157285.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!