温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android安装卸载程序的具体操作方法

发布时间:2021-11-11 15:57:19 阅读:216 作者:柒染 栏目:移动开发
Android开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

Android安装卸载程序的具体操作方法,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

对于编程爱好者们来说,Android手机操作系统是一款非常实用的系统。他们可以进行各种Android应用程序的开发来满足自的应用需求。在这里我们就先来为大家讲解一下有关Android安装卸载程序的具体操作步骤。

在Android安装卸载程序的源码中我们知道:

< activity android:name=".PackageInstallerActivity">   < intent-filter>   < action android:name="android.intent.action.VIEW" />   < category android:name="android.intent.category.DEFAULT" />   < data android:scheme="content" />   < data android:scheme="file" />   < data android:mimeType="application/vnd.android.package-archive" />   < /intent-filter>   < /activity>   < activity android:name=".UninstallerActivity">   < intent-filter>   < action android:name="android.intent.action.VIEW" />   < action android:name="android.intent.action.DELETE" />   < category android:name="android.intent.category.DEFAULT" />   < data android:scheme="package" />   < /intent-filter>   < /activity>

因为根据里面的权限我们可以 安装一个程序从sd卡:

String fileName = Environment.getExternalStorageDirectory() + "/myApp.apk";   Intent intent = new Intent(Intent.ACTION_VIEW);   intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");   startActivity(intent);  

Android安装卸载程序的操作中要想卸载一个程序;

Uri packageURI = Uri.parse("package:com.android.myapp");   Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);   startActivity(uninstallIntent);  

默认是不支持安装非市场程序的 因此判断一下

int result = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, 0);   if (result == 0) {   // show some dialog here   // ...   // and may be show application settings dialog manually   Intent intent = new Intent();   intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);   startActivity(intent);   } 

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×