@Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   File filesDir = getFilesDir();
   String dataDir = filesDir.getParent();
   dbDir = dataDir + "/databases";
   backup = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Acfun";
   setContentView(R.layout.activity_splash);
   mHandler.sendEmptyMessageDelayed(0, 1200L);
   // 版本号更改后,清除原有缓存
   try {
     PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
     int oldVersion = AcApp.getConfig().getInt("versionCode", 0);
     if (oldVersion != info.versionCode) {
       clearCache();
       AcApp.putInt("versionCode", info.versionCode);
     }
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   File bak = new File(backup + appDb);
   if (bak.exists()) {
     new Thread() {
       public void run() {
         copy(backup + appDb, dbDir + appDb);
         copy(backup + downloadDb, dbDir + downloadDb);
         new File(backup + appDb).delete();
         new File(backup + downloadDb).delete();
       }
     }.start();
   }
 }
 /**
  * @param paramContext context
  * @since I used to be a programmer like you, then I took an arrow in the kneeVer 1.0
  */
 public void getDeviceInfo(Context paramContext) {
   try {
     PackageManager mPackageManager = paramContext.getPackageManager();
     PackageInfo mPackageInfo =
         mPackageManager.getPackageInfo(
             paramContext.getPackageName(), PackageManager.GET_ACTIVITIES);
     if (mPackageInfo != null) {
       String versionName = mPackageInfo.versionName == null ? "null" : mPackageInfo.versionName;
       String versionCode = mPackageInfo.versionCode + "";
       mDeviceInfo.put("versionName", versionName);
       mDeviceInfo.put("versionCode", versionCode);
     }
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   Field[] mFields = Build.class.getDeclaredFields();
   for (Field field : mFields) {
     try {
       field.setAccessible(true);
       mDeviceInfo.put(field.getName(), field.get("").toString());
       Log.d(TAG, field.getName() + ":" + field.get(""));
     } catch (IllegalArgumentException e) {
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     }
   }
 }
Exemple #3
0
  private void runApp(List<MainListItem> items) {
    // 起動中のアプリ情報を取得
    Intent it = new Intent(Intent.ACTION_MAIN);
    it.addCategory(Intent.CATEGORY_LAUNCHER);
    List<RunningAppProcessInfo> runningApp = activityManager.getRunningAppProcesses();
    List<RunningServiceInfo> runningService = activityManager.getRunningServices(100);
    List<ResolveInfo> appList = packageManager.queryIntentActivities(it, 0);

    if (runningApp != null) {
      for (RunningAppProcessInfo app : runningApp) {
        try {
          // アプリ名をリストに追加
          ApplicationInfo appInfo = packageManager.getApplicationInfo(app.processName, 0);
          items.add(
              new MainListItem(
                  packageManager.getApplicationIcon(appInfo),
                  returnLabel(app.processName),
                  app.processName,
                  app.pid,
                  usageMemory(app.pid),
                  0,
                  true,
                  app.importance,
                  serviceClassNames(runningService, app),
                  mainClassName(appList, app)));
        } catch (NameNotFoundException e) {
          e.printStackTrace();
        }
      }
    }
  }
  @SuppressWarnings("nls")
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.about);

    Bundle extras = getIntent().getExtras();
    String packageName = null;
    if (extras != null) {
      packageName = extras.getString(LibraryConstants.PREFS_KEY_TEXT);
    }

    try {
      AssetManager assetManager = this.getAssets();
      InputStream inputStream = assetManager.open("about.html");
      String htmlText = new Scanner(inputStream).useDelimiter("\\A").next();

      if (packageName != null) {
        String version = "";
        try {
          PackageInfo pInfo =
              getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA);
          version = pInfo.versionName;
        } catch (NameNotFoundException e) {
          e.printStackTrace();
        }

        htmlText = htmlText.replaceFirst("VERSION", version);
      }

      WebView aboutView = (WebView) findViewById(R.id.aboutview);
      aboutView.loadData(htmlText, "text/html", "utf-8");
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  private static List<String> getPackageDatas(Context context) {

    List<String> packageDatas = new ArrayList<String>();

    PackageManager packageManager = context.getPackageManager();
    List<ApplicationInfo> list =
        packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
    for (ApplicationInfo appInfo : list) {
      StringBuffer data = new StringBuffer();
      try {
        PackageInfo packageInfo =
            packageManager.getPackageInfo(appInfo.packageName, PackageManager.GET_META_DATA);
        data.append(appInfo.packageName); // パッケージ名
        data.append(",");
        data.append(packageInfo.versionName); // バージョン
      } catch (NameNotFoundException e) {
        e.printStackTrace();
      }
      packageDatas.add(data.toString());
    }
    Collections.sort(
        packageDatas,
        new Comparator<String>() {

          public int compare(String lhs, String rhs) {
            return lhs.compareTo(rhs);
          }
        });
    return packageDatas;
  }
  private void refreshList() {
    if (iFavoritesService == null) {
      Log.i(TAG, "refreshList iFavoritesService null");
      return;
    }
    try {
      List<String> favoritesPackageList = iFavoritesService.getFavoritesMap();
      mAppInfoList.clear();
      for (String packageName : favoritesPackageList) {
        ApplicationInfo applicationInfo;
        try {
          applicationInfo = mPackageManager.getApplicationInfo(packageName, 0);
          FavoritesAppInfo appInfo = new FavoritesAppInfo();
          appInfo.packageName = applicationInfo.packageName;
          appInfo.appName = applicationInfo.loadLabel(mPackageManager).toString();
          appInfo.appIntent =
              mPackageManager.getLaunchIntentForPackage(applicationInfo.packageName);
          appInfo.appIcon = applicationInfo.loadIcon(mPackageManager);
          mAppInfoList.add(appInfo);
        } catch (NameNotFoundException e) {
          e.printStackTrace();
        }
      }
    } catch (RemoteException e) {
      e.printStackTrace();
    }

    Intent intent = new Intent(FavoritesModel.ACTION_LOAD_FAVOTITE_SUCCESS);
    mContext.sendBroadcast(intent);
  }
  @Override
  public void onCreate() {
    Utils.logger("d", "service created", DEBUG_TAG);
    BugSenseHandler.initAndStartSession(this, YTD.BugsenseApiKey);
    BugSenseHandler.leaveBreadcrumb("AutoUpgradeApkService_onCreate");
    registerReceiver(apkReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

    try {
      currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
      Utils.logger("d", "current version: " + currentVersion, DEBUG_TAG);
    } catch (NameNotFoundException e) {
      Log.e(DEBUG_TAG, "version not read: " + e.getMessage());
      currentVersion = "100";
    }
    ConnectivityManager connMgr =
        (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected() && matchedVersion != "n.a.") {
      try {
        // init version and changelog
        matchedChangeLog = null;
        matchedVersion = null;

        asyncAutoUpdate = new AsyncUpdate();
        webPage = "http://sourceforge.net/projects/ytdownloader/files/";
        asyncAutoUpdate.execute(webPage);
      } catch (NullPointerException e) {
        Log.e(DEBUG_TAG, "unable to retrieve update data.");
      }
    } else {
      Log.e(DEBUG_TAG, getString(R.string.no_net));
    }
  }
	private void loadThemeInformation(
			boolean reloadGallery )
	{
		ThemeService service = new ThemeService( this );
		themeInformation = service.queryTheme( packageName , destClassName );
		if( themeInformation.isInstalled() )
		{
			Context dstContext = null;
			try
			{
				dstContext = createPackageContext( packageName , Context.CONTEXT_IGNORE_SECURITY );
			}
			catch( NameNotFoundException e )
			{
				e.printStackTrace();
				return;
			}
			Log.v( LOG_TAG , "2222222222222222destClassName = " + destClassName );
			ContentConfig destContent = new ContentConfig();
			destContent.loadConfig( dstContext , destClassName );
			themeInformation.loadInstallDetail( dstContext , destContent );
			if( reloadGallery )
			{
				themeLocalAdapter = new ThemePreviewLocalAdapter( this , destContent , dstContext , false );
				galleryPreview.setAdapter( themeLocalAdapter );
			}
			return;
		}
		if( reloadGallery )
		{
			galleryPreview.setAdapter( new ThemePreviewHotAdapter( this , packageName , downModule , false ) );
		}
	}
 @SuppressWarnings("unchecked")
 @Override
 public void onReceive(Context context, Intent intent) {
   ComponentName receiver = new ComponentName(context, this.getClass());
   try {
     Bundle metaData =
         context
             .getPackageManager()
             .getReceiverInfo(receiver, PackageManager.GET_META_DATA)
             .metaData;
     int iconId = metaData.getInt(METADATA_ICON_KEYNAME, -1);
     String activityName = metaData.getString(METADATA_ACTIVITY_KEYNAME);
     if (iconId == -1) {
       Log.e(
           "Scoreflex",
           "You should specify a <meta-data android:name=\"notificationIcon\" android:resource=YourApplicationIcon/> in your Receiver definition of your AndroidMabnifest.xml");
       return;
     }
     if (activityName == null) {
       Log.e(
           "Scoreflex",
           "You should specify a <meta-data android:name=\"activityName\" android:value=YourMainActivity/> in your Receiver definition of your AndroidMabnifest.xml");
       return;
     }
     ScoreflexGcmClient.onBroadcastReceived(
         context, intent, iconId, (Class<? extends Activity>) Class.forName(activityName));
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     Log.e(
         "Scoreflex", "The activity you provided in  android:name=\"activityName\" doesn't exist");
     e.printStackTrace();
   }
 }
Exemple #10
0
  public void init() {
    instance = this;

    session = new HashMap<String, Object>();
    activityManager = new ArrayList<Activity>();
    if (fileDir != null) {
      imageLoader =
          new ImageLoader(
              instance, defaultImageId, fileDir); // 使用ImageLoader组件时,设置defaultImageId、fileDir
    } else {
      imageLoader = new ImageLoader(instance, defaultImageId); // 使用ImageLoader组件时,设置defaultImageId
    }

    PackageManager manager = this.getPackageManager();
    try {
      PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
      deviceid = getDeviceId();
      osVersion = Build.VERSION.RELEASE;
      mobileType = Build.MODEL;
      if (null != info) {
        version = info.versionName;
        versionCode = info.versionCode;
      }
    } catch (NameNotFoundException e) {
      e.printStackTrace();
    }
  }
  public static String logKeyHash(Activity context) {
    PackageInfo packageInfo;
    String key = null;
    try {
      // getting application package name, as defined in manifest
      String packageName = context.getApplicationContext().getPackageName();

      // Retriving package info
      packageInfo =
          context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);

      Log.e("Package Name=", context.getApplicationContext().getPackageName());

      for (Signature signature : packageInfo.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        key = new String(Base64.encode(md.digest(), 0));

        // String key = new String(Base64.encodeBytes(md.digest()));
        Log.e("Key Hash=", key);
      }
    } catch (NameNotFoundException e1) {
      Log.e("Name not found", e1.toString());
    } catch (NoSuchAlgorithmException e) {
      Log.e("No such an algorithm", e.toString());
    } catch (Exception e) {
      Log.e("Exception", e.toString());
    }

    return key;
  }
Exemple #12
0
 public void collectCrashDeviceInfo(Context ctx) {
   try {
     PackageManager pm = ctx.getPackageManager();
     PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
     if (pi != null) {
       mDeviceCrashInfo.put(VERSION_NAME, pi.versionName == null ? "not set" : pi.versionName);
       mDeviceCrashInfo.put(VERSION_CODE, pi.versionCode);
     }
   } catch (NameNotFoundException e) {
     if (Constant.DEBUG) {
       e.printStackTrace();
     }
     // Log.e(TAG, "Error while collect package info", e);
   }
   Field[] fields = Build.class.getDeclaredFields();
   for (Field field : fields) {
     try {
       field.setAccessible(true);
       mDeviceCrashInfo.put(field.getName(), field.get(null));
       if (Constant.DEBUG) {
         System.out.println(field.getName() + " : " + field.get(null));
       }
     } catch (Exception e) {
       if (Constant.DEBUG) {
         e.printStackTrace();
       }
       // Log.e(TAG, "Error while collect crash info", e);
     }
   }
 }
Exemple #13
0
  public static void initLogging(Context context) {
    int flags;
    boolean verboseLogging = false;
    try {
      flags =
          context
              .getPackageManager()
              .getPackageInfo(context.getPackageName(), 0)
              .applicationInfo
              .flags;
      verboseLogging = ((flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
    } catch (NameNotFoundException e) {
      e.printStackTrace();
      return;
    }

    if (!verboseLogging) {
      return;
    }

    String verboseLoggingProp = readSystemProperty("nativescript.verbose.logging");
    if (verboseLoggingProp.equals("true")
        || verboseLoggingProp.equals("TRUE")
        || verboseLoggingProp.equals("yes")
        || verboseLoggingProp.equals("YES")
        || verboseLoggingProp.equals("enabled")
        || verboseLoggingProp.equals("ENABLED")) {
      Platform.IsLogEnabled = true;
    }
  }
  /**
   * 注册PUSH服务
   *
   * @param schoolid
   * @param schoolkey
   * @throws RemoteException
   */
  public static void Register(String schoolid, String schoolkey) throws RemoteException {
    String packageName = mContext.getPackageName();
    PushRegItem regItem = new PushRegItem();
    regItem.packageName = packageName;
    regItem.SchoolID = schoolid;
    regItem.SchoolKey = schoolkey;
    regItem.appver = "";
    PackageManager packageManager = mContext.getPackageManager();
    try {
      PackageInfo packInfo = packageManager.getPackageInfo(mContext.getPackageName(), 0);
      regItem.appver = packInfo.versionName;
    } catch (NameNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    mDrPalmPushService.RegAppPush(
        regItem,
        new IDrPalmPushCallback.Stub() {
          @Override
          public void onError(String err) throws RemoteException {
            //				callback.onError(err);
          }

          @Override
          public void onSuccess() throws RemoteException {
            //				callback.onSuccess();
          }
        });
  }
  /**
   * Sets Texts views to display statistics of Poses being received. This also sets the buttons used
   * in the UI. Please note that this needs to be called after TangoService and Config objects are
   * initialized since we use them for the SDK related stuff like version number etc.
   */
  private void setupTextViewsAndButtons(TangoConfig config) {
    // Text views for displaying translation and rotation data
    mPoseTextView = (TextView) findViewById(R.id.pose);
    mQuatTextView = (TextView) findViewById(R.id.quat);
    mPoseCountTextView = (TextView) findViewById(R.id.posecount);
    mDeltaTextView = (TextView) findViewById(R.id.deltatime);
    mTangoEventTextView = (TextView) findViewById(R.id.tangoevent);

    // Text views for the status of the pose data and Tango library versions
    mPoseStatusTextView = (TextView) findViewById(R.id.status);
    mTangoServiceVersionTextView = (TextView) findViewById(R.id.version);
    mApplicationVersionTextView = (TextView) findViewById(R.id.appversion);

    // Buttons for selecting camera view and Set up button click listeners
    findViewById(R.id.first_person_button).setOnClickListener(this);
    findViewById(R.id.third_person_button).setOnClickListener(this);
    findViewById(R.id.top_down_button).setOnClickListener(this);

    // Button to reset motion tracking
    mMotionResetButton = (Button) findViewById(R.id.resetmotion);
    // Set up button click listeners
    mMotionResetButton.setOnClickListener(this);

    // Display the library version for debug purposes
    mTangoServiceVersionTextView.setText(config.getString("tango_service_library_version"));
    PackageInfo packageInfo;
    try {
      packageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
      mApplicationVersionTextView.setText(packageInfo.versionName);
    } catch (NameNotFoundException e) {
      e.printStackTrace();
    }
  }
 public static String getVersionName(Context context) {
   try {
     return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return null;
 }
 public PackageHelper() {
   pm = ApplicationBean.getApplication().getPackageManager();
   try {
     info = pm.getPackageInfo(ApplicationBean.getApplication().getPackageName(), 0);
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
 }
Exemple #18
0
 protected String returnLabel(String tag) {
   try {
     return (String) packageManager.getApplicationLabel(packageManager.getApplicationInfo(tag, 0));
   } catch (NameNotFoundException e) {
     e.printStackTrace();
     return null;
   }
 }
 /**
  * 从包信息中获取版本号
  *
  * @param context
  * @return
  */
 private static int getVersionCode(Context context) {
   try {
     return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return -1;
 }
 /** 获取当前客户端版本信息 */
 private void getCurrentVersion() {
   try {
     PackageInfo info = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
     curVersionCode = info.versionCode;
   } catch (NameNotFoundException e) {
     e.printStackTrace(System.err);
   }
 }
 public int getVersion() {
   int v = 0;
   try {
     v = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return v;
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   try {
     DownloaderClientMarshaller.startDownloadServiceIfRequired(
         context, intent, MapFileDownloaderService.class);
   } catch (NameNotFoundException e) {
     Log.e("apk-expansion-files", "NameNotFoundException occurred. " + e.getMessage(), e);
   }
 } // onReceive
 public PackageInfo getPackageInfo(String packageName) {
   try {
     return context.getPackageManager().getPackageInfo(packageName, 0);
   } catch (NameNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return null;
   }
 }
Exemple #24
0
 /*
  * 获取程序 图标
  */
 public Drawable getAppIcon(String packname) {
   try {
     ApplicationInfo info = pm.getApplicationInfo(packname, 0);
     return info.loadIcon(pm);
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return null;
 }
Exemple #25
0
 private String getVersion() {
   try {
     PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
     return pInfo.versionName;
   } catch (NameNotFoundException e) {
     e.printStackTrace();
     return "1.1";
   }
 }
Exemple #26
0
 /*
  * 获取程序的名字
  */
 public String getAppName(String packname) {
   try {
     ApplicationInfo info = pm.getApplicationInfo(packname, 0);
     return info.loadLabel(pm).toString();
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return "";
 }
  /** Loads settings, either from manifest or {@link Settings}. */
  private void loadSettings() {
    Bundle metaData = null;
    try {
      metaData =
          getPackageManager()
              .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA)
              .metaData;
    } catch (NameNotFoundException e) {
      /*
       * Never catch this.
       */
      e.printStackTrace();
    }

    if (metaData != null && metaData.containsKey(METADATA_MIN_WIRED_DOTS))
      mMinWiredDots =
          Settings.Display.validateMinWiredDots(this, metaData.getInt(METADATA_MIN_WIRED_DOTS));
    else mMinWiredDots = Settings.Display.getMinWiredDots(this);

    if (metaData != null && metaData.containsKey(METADATA_MAX_RETRIES))
      mMaxRetries =
          Settings.Display.validateMaxRetries(this, metaData.getInt(METADATA_MAX_RETRIES));
    else mMaxRetries = Settings.Display.getMaxRetries(this);

    if (metaData != null && metaData.containsKey(METADATA_AUTO_SAVE_PATTERN))
      mAutoSave = metaData.getBoolean(METADATA_AUTO_SAVE_PATTERN);
    else mAutoSave = Settings.Security.isAutoSavePattern(this);

    if (metaData != null && metaData.containsKey(METADATA_CAPTCHA_WIRED_DOTS))
      mCaptchaWiredDots =
          Settings.Display.validateCaptchaWiredDots(
              this, metaData.getInt(METADATA_CAPTCHA_WIRED_DOTS));
    else mCaptchaWiredDots = Settings.Display.getCaptchaWiredDots(this);

    if (metaData != null && metaData.containsKey(METADATA_STEALTH_MODE))
      mStealthMode = metaData.getBoolean(METADATA_STEALTH_MODE);
    else mStealthMode = Settings.Display.isStealthMode(this);

    /*
     * Encrypter.
     */
    char[] encrypterClass;
    if (metaData != null && metaData.containsKey(METADATA_ENCRYPTER_CLASS))
      encrypterClass = metaData.getString(METADATA_ENCRYPTER_CLASS).toCharArray();
    else encrypterClass = Settings.Security.getEncrypterClass(this);

    if (encrypterClass != null) {
      try {
        mEncrypter =
            (IEncrypter)
                Class.forName(new String(encrypterClass), false, getClassLoader()).newInstance();
      } catch (Throwable t) {
        throw new InvalidEncrypterException();
      }
    }
  } // loadSettings()
Exemple #28
0
 /**
  * 获取versionCode(通过versionCode判断是否需要更新客户端)
  *
  * @param context 上下文
  * @return versionCode
  */
 public static int getVersionCode(Context context) {
   try {
     PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
     return pi.versionCode;
   } catch (NameNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return 0;
 }
Exemple #29
0
 private void getNowVersion() {
   String pName = "com.qizhi.qilaiqiqu";
   try {
     PackageInfo pinfo =
         this.getPackageManager().getPackageInfo(pName, PackageManager.GET_CONFIGURATIONS);
     nowTxt.setText(pinfo.versionName);
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
 }
Exemple #30
0
 private int getVersionCode(Context context) {
   int versionCode = 0;
   try {
     versionCode =
         context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return versionCode;
 }