コード例 #1
0
 @Override
 public boolean onPreferenceClick(Preference preference) {
   if ("createShortCut".equals(preference.getKey())) {
     createShortCut();
   } else if ("pVersion".equals(preference.getKey())) {
     UmengUpdateAgent.forceUpdate(getActivity());
     UmengUpdateAgent.setUpdateListener(
         new UmengUpdateListener() {
           @Override
           public void onUpdateReturned(int i, UpdateResponse updateResponse) {
             if (i != 0) {
               T.showLong(getActivity(), "当前版本为最新版本!");
             }
           }
         });
   } else if ("pVersionDetail".equals(preference.getKey())) {
     VersionFragment.launch(getActivity());
   } else if ("pGithub".equals(preference.getKey())) {
     Utils.launchBrowser(getActivity(), "https://github.com/joyoyao/superCleanMaster");
   } else if ("pGrade".equals(preference.getKey())) {
     startMarket();
   } else if ("pShare".equals(preference.getKey())) {
     shareMyApp();
   } else if ("pAbout".equals(preference.getKey())) {
     getActivity().startActivity(new Intent(getActivity(), AboutActivity.class));
   }
   return false;
 }
コード例 #2
0
 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(), "无法打开应用市场");
   }
 }