Android调用系统功能、apk安装卸载
来源:互联网 发布:seo常用工具 编辑:程序博客网 时间:2024/04/27 15:10
Android调用系统功能、apk安装卸载
分类: Android开发2013-09-09 12:57 2964人阅读 评论(0) 收藏 举报
apk系统AndroidIntent
使用网络io读写api获取网络apk文件,并调用系统服务进行安装;
网络读取必须放于线程中进行;
1、安装apk
- String dirPath = "/data/data/" + getPackageName() + "/files/test.apk"; //文件需有可读权限
- Intent intent = new Intent();
- intent.setAction(android.content.Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
2、卸载apk
方法一(已测试):
- Uri packageUri = Uri.parse("package:" + appUnit.pname);
- Intent deleteIntent = new Intent();
- deleteIntent.setAction(Intent.ACTION_DELETE);
- deleteIntent.setData(packageUri);
- context.startActivity(deleteIntent);
方法二(未测试):
- private void startUninstall(final String pkg) {
- if (!InstallUtils.isApkInstalled(mContext, pkg)) {
- Toast.makeText(mContext, "程序未安装,无需卸载!", Toast.LENGTH_SHORT).show();
- return;
- } else {
- Uri packageURI = Uri.parse("package:" + pkg);
- Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
- startActivity(uninstallIntent);
- }
- }
3. 启动Android默认浏览器(已测试)
- Intent intent= new Intent();
- intent.setAction("android.intent.action.VIEW");
- Uri content_url = Uri.parse("http://www.cnblogs.com");
- intent.setData(content_url);
- startActivity(intent);
这样子,android就可以调用起手机默认的浏览器访问。
以下内容均来自转载。未经测试。附带电话号码(调用系统短信):
- Intent mIntent = new Intent(Intent.ACTION_VIEW);
- mIntent.putExtra("address",phoneNum);
- mIntent.putExtra("sms_body", "");
- mIntent.setType("vnd.android-dir/mms-sms");
- context.startActivity(mIntent);
附带短信内容(调用系统短信):
- Uri smsToUri = Uri.parse("smsto:");// 联系人地址
- Intent mIntent = new Intent(android.content.Intent.ACTION_SENDTO,
- smsToUri);
- mIntent.putExtra("sms_body",
- "abcdefgh");// 短信内容
- context.startActivity(mIntent);
- Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
- // 文本格式
- emailIntent.setType("text/plain");
- // 对方邮件地址
- emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "");
- // 标题内容
- emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
- // 邮件文本内容
- emailIntent
- .putExtra(android.content.Intent.EXTRA_TEXT,
- "abcdefgh");
- context.startActivity(Intent.createChooser(emailIntent,
- "Choose Email Client"));
调用系统添加联系人:
- Intent intent = new Intent(Intent.ACTION_INSERT,
- Contacts.CONTENT_URI);
- intent.putExtra("name", "");
- intent.putExtra("phone", number);
- context.startActivity(intent);
- Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
- intent.setType("vnd.android.cursor.item/contact");
- intent.putExtra(Intents.Insert.PHONE, number);
- context.startActivity(intent);
- Intent i = new Intent(Intent.ACTION_EDIT);
- i.setData(ContentUris.withAppendedId(ContactsContract.Contacts.CONTE
0 0
- Android调用系统功能、apk安装卸载
- Android调用系统功能、apk安装卸载
- Android调用系统安装/卸载apk过程
- android:卸载系统apk,安装apk
- android调用系统安装apk
- android安装卸载apk
- Android安装/卸载apk
- android 安装/卸载apk
- android 安装卸载apk
- 研究 android apk安装卸载等 产生的 系统广播
- 研究 android apk安装卸载等 产生的 系统广播
- Android安装卸载apk包
- android安装及卸载apk
- Android安装卸载apk包
- Android apk的安装、卸载
- Android安装卸载APK(Intent)
- android 安装和卸载apk
- ANDROID调用卸载软件功能
- 常用Petri网模拟软件工具简介
- webstorm的快捷键说明
- poi生成Excel
- (原创) 心电图机静态心电自动分析算法介绍
- 博客收藏
- Android调用系统功能、apk安装卸载
- Swift Nullability and Objective-C
- Linux网络编程:原始套接字的魔力【上】
- 字符串哈希函数
- OJ 56之Hamming Distance
- 解压rpm包
- Ruby 中的$LOAD_PATH,Require,Load,Include和Extend介绍
- 引用类型 与 基本包装类型
- OJ 66之日期计算