Intent 、Intent Filter 和传输数据

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

 

posted @ 2014-12-11 11:59  菜鸟的学习  阅读(210)  评论(0编辑  收藏  举报