public void startMarket() { Uri uri = Uri.parse( String.format( "market://details?id=%s", AppUtil.getPackageInfo(getActivity()).packageName)); if (Utils.isIntentSafe(getActivity(), uri)) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getActivity().startActivity(intent); } // 没有安装市场 else { T.showLong(getActivity(), "无法打开应用市场"); } }
private void createShortCut() { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "一键加速"); intent.putExtra("duplicate", false); intent.putExtra( Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.short_cut_icon)); Intent i = new Intent(); i.setAction("com.yzy.shortcut"); i.addCategory("android.intent.category.DEFAULT"); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i); getActivity().sendBroadcast(intent); T.showLong(getActivity(), "“一键加速”快捷图标已创建"); }