Android 启动第三方程序的方法总结
程序员文章站
2022-05-20 22:13:27
android 启动第三方程序的方法总结
方法一:
intent intent = new intent();
intent.setclassname(...
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);
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
上一篇: 枸杞红糖姜茶的做法