检测手机中是否安装了google地图,没有则提示安装,并跳转到地图查找特定的地点


     /**
* 检测手机中是否安装了某个特定的app,若没有提示安装 */ PackageInfo name_2 = null; try { // 若没有这个包名会异常 name_2 = getPackageManager().getPackageInfo( "com.google.android.apps.maps", 0); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); File file = new File("/sdcard/google_map.apk"); // 打开特定位置的app提示安装 openFile(file); }
   /*
     * 通过路径打开特定的app安装包
     */
    private void openFile(File file) {
        // TODO Auto-generated method stub
        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file),
                "application/vnd.android.package-archive");
        startActivity(intent);
    }
     //跳转到地图,查找特定的位置
        String name_1 = "北店嘉园";
        Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                Uri.parse("geo:0,0?q=" + name_1));
        startActivity(intent);

 

posted @ 2013-08-12 11:51  有情怀的人  阅读(522)  评论(0)    收藏  举报