效果图例如以下:
代码例如以下:
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 情绪控_