应用里面调用安装应用的方法

废话少说,上代码~~~~

Button button;
    String DOWNLOAD_VERSION_MORE_APP = File.separator
            + "test" + File.separator + "app" + File.separator + "QQ.apk";
    String path;


 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button = (Button)this.findViewById(R.id.button);
        button.setOnClickListener(this);
        path = Environment.getExternalStorageDirectory()+DOWNLOAD_VERSION_MORE_APP;
        System.out.println(path);
    }

@Override
    public void onClick(View v) {
         Uri uri = Uri.fromFile(new File(path));
         Intent installIntent = new Intent(Intent.ACTION_VIEW);
         installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
         startActivity(installIntent);
    }

不解释,很简单明了了。其实说实话,我也不会解释~~~~~~~~Y(^_^)Y

posted @ 2012-09-13 11:24  柱柱  阅读(260)  评论(1编辑  收藏  举报