Android之如何卸载指定的 应用程序

效果图如下:

 

 

 

 

代码如下:

 

public class MainActivity extends Activity {
	private Button btn_delete;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initView();
		
	}

	private void initView(){
		btn_delete=(Button)findViewById(R.id.btn_delete);
		btn_delete.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String packagename = "com.mobilesafe";
				Intent deleteIntent = new Intent();
				deleteIntent.setAction(Intent.ACTION_DELETE);
				deleteIntent.setData(Uri
						.parse("package:" + packagename));
				startActivityForResult(deleteIntent, 0);	
			}
		});
	}

	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		Toast.makeText(MainActivity.this, "卸载成功!", Toast.LENGTH_LONG);
	}
	
}


以上packagename指的是你想要卸载应用程序的包名,也就是AndroidManifest.xml中的package指定的内容

 

 

 

 

转载请注明出处:http://blog.csdn.net/hai_qing_xu_kong/article/details/44263287 情绪控_

©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:上身试试 返回首页