关闭

安卓卸载一个程序的代码

152人阅读 评论(0) 收藏 举报
<span style="font-size:18px;"><span style="white-space:pre">			</span>Intent intent2 = new Intent();
			intent2.setAction("android.intent.action.VIEW");
			intent2.setAction("android.intent.action.DELETE");
			intent2.addCategory("android.intent.category.DEFAULT");</span>
<span style="font-size:18px;"><span style="white-space:pre">			</span>//</span><span style="font-size: 18px; font-family: Arial, Helvetica, sans-serif;">appinfo.getPackageName()是得到要卸载的程序的包名</span><span style="font-size:18px;">
<span style="white-space:pre">			</span>intent2.setData(Uri.parse("package:" + appinfo.getPackageName()));
			startActivityForResult(intent2, 0);</span>
</pre><p><span style="font-family:monospace;font-size:18px;"><span style="white-space: pre;"><span style="white-space:pre">	</span></span></span></p><p><span style="font-family:monospace;font-size:18px;"></span></p><p><span style="font-family:monospace;font-size:18px;white-space: pre;">程序卸载后如果要做相应的处理,就在启动Activity的回调函数里操作</span></p><p><span style="font-family:monospace;font-size:18px;white-space: pre;"></span></p><p><span style="font-family:monospace;font-size:18px;white-space: pre;"></span><pre name="code" class="java">@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		Log.i("huang", "resultCode:"+requestCode);
		if(isClickUserApp){
			userApps.remove(newposition);
		}
		else{
			systemApps.remove(newposition);
		}
<span style="white-space:pre">		</span>//刷新listView
		myAdapter.notifyDataSetChanged();
	}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:20152次
    • 积分:655
    • 等级:
    • 排名:千里之外
    • 原创:46篇
    • 转载:12篇
    • 译文:0篇
    • 评论:1条