当前位置: 移动技术网 > 移动技术>移动开发>Android > Android 启动第三方程序的方法总结

Android 启动第三方程序的方法总结

2019年07月24日  | 移动技术网移动技术  | 我要评论

android 启动第三方程序的方法总结

方法一:

intent intent = new intent(); 
intent.setclassname(<package name>, <class name>); 
startactivity(intent);

方法二:

intent i=new intent;
componentname com= new componentname(<package name> , <calss name>); 
i.setcomponent(com); 
startactivity(i); 

启动媒体库

intent i = new intent();

componentname comp = new componentname("com.android.camera","com.android.camera.gallerypicker");

i.setcomponent(comp);

i.setaction("android.intent.action.view");

startactivity(i);

启动相机

intent mintent = new intent();

componentname comp = new componentname("com.android.camera","com.android.camera.camera");

mintent.setcomponent(comp);

mintent.setaction("android.intent.action.view");

startactivity(mintent);

启动htmlviewer,并打开指定的一个文件 注意txt不能是ansi的,否则会乱码

intent intent = new intent();

componentname cn = new componentname("com.android.htmlviewer", "com.android.htmlviewer.htmlvieweractivity");

intent.setcomponent(cn);

uri uri = uri.fromfile(new file("/sdcard/demo.txt"));

intent.setdataandtype(uri, "text/plain");

startactivity(intent);

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网