List of usage examples for android.content Context ACTIVITY_SERVICE
String ACTIVITY_SERVICE
To view the source code for android.content Context ACTIVITY_SERVICE.
Click Source Link
From source file:me.trashout.fragment.DashboardFragment.java
private boolean isTrashHunterServiceRunning() { ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (TrashHunterService.class.getName().equals(service.service.getClassName())) { return true; }// w ww .j a v a2 s . c o m } return false; }
From source file:com.lewa.crazychapter11.MainActivity.java
private void refreshDesk() { ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); try {/*from w w w . j a v a 2 s. c o m*/ Log.i("algerheTest", "refreshDesk()----->clear user data"); Method clearUserdata = am.getClass().getDeclaredMethod("clearApplicationUserData", String.class, IPackageDataObserver.class); clearUserdata.setAccessible(true); clearUserdata.invoke(am, "com.android.launcher", new PackageDataClearObserver()); } catch (Exception e) { //TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.uguess.android.sysinfo.SiragonManager.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final Activity ctx = getActivity(); if (item.getItemId() == MI_PREFERENCE) { Intent it = new Intent(ctx, InfoSettings.class); it.putExtra(PREF_KEY_SHOW_INFO_ICON, Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_SHOW_INFO_ICON)); it.putExtra(PREF_KEY_SHOW_TASK_ICON, Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_SHOW_TASK_ICON)); it.putExtra(PREF_KEY_AUTO_START_ICON, Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_AUTO_START_ICON, false)); it.putExtra(PREF_KEY_DEFAULT_SERVER, Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_SERVER, null)); it.putExtra(PREF_KEY_DEFAULT_EMAIL, Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_EMAIL, null)); it.putExtra(PREF_KEY_DEFAULT_TAB, Util.getIntOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_TAB, 0)); it.putExtra(PREF_KEY_WIDGET_DISABLED, Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_WIDGET_DISABLED, null)); startActivityForResult(it, 2);// w ww .ja v a2s .co m return true; } else if (item.getItemId() == MI_HELP) { Intent it = new Intent(Intent.ACTION_VIEW); String target = "http://www.siragon.com.ve"; //$NON-NLS-1$ ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (info != null && info.isConnected()) { target = "http://www.siragon.com.ve"; //$NON-NLS-1$ } it.setData(Uri.parse(target)); it = Intent.createChooser(it, null); startActivity(it); return true; } ///////////////////////PATH SERVER/////////////////////////////////// else if (item.getItemId() == MI_ABOUT) { ScrollView sv = new ScrollView(ctx); TextView txt = new TextView(ctx); txt.setGravity(Gravity.CENTER_HORIZONTAL); txt.setTextAppearance(ctx, android.R.style.TextAppearance_Medium); sv.addView(txt); String href = "http://www.google.com.ve"; //$NON-NLS-1$ txt.setText(Html.fromHtml(getString(R.string.about_msg, getVersionName(ctx.getPackageManager(), ctx.getPackageName()), href))); txt.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(ctx).setTitle(R.string.app_name).setIcon(R.drawable.logo2).setView(sv) .setNegativeButton(R.string.close, null).create().show(); return true; } else if (item.getItemId() == MI_EXIT) { OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { Util.killSelf(handler, ctx, (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE), ctx.getPackageName()); } }; new AlertDialog.Builder(ctx).setTitle(R.string.prompt).setMessage(R.string.exit_prompt) .setPositiveButton(android.R.string.yes, listener).setNegativeButton(android.R.string.no, null) .create().show(); return true; } else if (item.getItemId() == MI_REFRESH) { updateInfo(); return true; } return false; }
From source file:com.oakesville.mythling.MediaActivity.java
private boolean isPlayingMusic() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MusicPlaybackService.class.getName().equals(service.service.getClassName())) return true; }//from ww w . ja v a 2s .c o m return false; }
From source file:org.uguess.android.sysinfo.SiragonManager.java
String generateTextReport(boolean[] items) { StringBuffer sb = new StringBuffer(); createTextHeader(getActivity(), sb, "Android Sragon Report - I&D " //$NON-NLS-1$ + new Date().toLocaleString()); if (items[BASIC_INFO]) { sb.append("####################\n"); sb.append(getString(R.string.tab_info)).append('\n'); sb.append(HEADER_SPLIT);/*from w w w. j a va 2 s .com*/ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.sd_storage)).append(":\n"); //$NON-NLS-1$ String[] info = getExternalStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_external, info[0], info[1]) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.a2sd_storage) + ":").append("\n"); //$NON-NLS-2$ info = getA2SDStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); sb.append("\n"); } else { sb.append(getString(R.string.storage_summary, info[0], info[1])); sb.append("\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.display) + ":").append("\n"); //$NON-NLS-2$ String[] info2 = getInfoDisplay(); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.info_display, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_back_img_support)).append("\n"); //$NON-NLS-1$ info2 = getSupportedPreviewSizes(0); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.support_image_back, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_back_vid_support)).append("\n"); //$NON-NLS-1$ info2 = getSupportedPreviewSizesVideo(0); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.support_video_back, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$ ////////////////////////////////////////////////////////////////////////////////// sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_other_feature) + ":").append("\n"); //$NON-NLS-2$ info2 = getSupportedOtherCamera(0); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.camera_des_feature, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_front_img_support)).append("\n"); //$NON-NLS-1$ info2 = getSupportedPreviewSizes(1); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.support_image_front, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_front_vid_support)).append("\n"); //$NON-NLS-1$ info2 = getSupportedPreviewSizesVideo(1); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.support_video_front, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_feature)).append("\n"); //$NON-NLS-1$} info2 = getAvailableFeatureCamera(); if (info2 == null) { sb.append(getString(R.string.info_not_available)); } else { for (int i = 0; i < info2.length; i++) { sb.append(getString(R.string.camera_all_feature, info2[i])).append("\n"); } } sb.append("####################\n"); //$NON-NLS-1$*/ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_back_available)).append(":").append("\n"); //$NON-NLS-2$ int cams = getNumberCamera(); if (cams == 0) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.number_cams, cams) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.camera_flash_available) + ":").append("\n"); //$NON-NLS-2$} boolean flash = getAvailableFlash(); if (flash == false) { sb.append(getString(R.string.info_not_available) + "\n"); } else { sb.append(getString(R.string.flash_available, flash) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ //////////////////////////////////////////////////////////////////////////////////////7 sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.internal_storage) + ":").append("\n"); //$NON-NLS-2$ info = getInternalStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available) + "\n"); } else { sb.append(getString(R.string.storage_summary, info[0], info[1]) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.system_storage)).append(":\n"); //$NON-NLS-1$ info = getSystemStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available) + "\n"); } else { sb.append(getString(R.string.storage_summary, info[0], info[1]) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.cache_storage)).append(":\n"); //$NON-NLS-1$ info = getCacheStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available) + "\n"); } else { sb.append(getString(R.string.storage_summary, info[0], info[1]) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.memory)).append(":\n"); //$NON-NLS-1$ info = getMemInfo(); if (info == null) { sb.append(getString(R.string.info_not_available) + "\n"); } else { sb.append(getString(R.string.storage_summary, info[0], info[2]) + getString(R.string.idle_info, info[1]) + "\n"); } sb.append("####################\n"); //$NON-NLS-1$ sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.processor) + ":").append("\n") //$NON-NLS-2$ .append(getCpuInfo() + "\n").append("####################\n"); //$NON-NLS-2$ String nInfo = getNetAddressInfo(); sb.append("* ") //$NON-NLS-1$ .append(getString(R.string.net_address) + ":").append("\n") //$NON-NLS-2$ .append(nInfo == null ? getString(R.string.info_not_available) + "\n" : nInfo + "\n") .append("####################\n"); //$NON-NLS-1$ //sb.append( '\n' ); try { File f = new File(F_SCALE_FREQ); if (f.exists()) { sb.append(getString(R.string.sc_freq)); readRawText(sb, new FileInputStream(f)); } else { sb.append(getString(R.string.no_sc_freq_info)).append('\n'); } sb.append("####################\n"); f = new File(F_CPU_INFO); if (f.exists()) { readRawText(sb, new FileInputStream(f)); } else { sb.append(getString(R.string.no_cpu_info)).append('\n'); } sb.append("####################\n"); f = new File(F_MEM_INFO); if (f.exists()) { readRawText(sb, new FileInputStream(f)); } else { sb.append(getString(R.string.no_mem_info)).append('\n'); } sb.append("####################\n"); f = new File(F_MOUNT_INFO); if (f.exists()) { readRawText(sb, new FileInputStream(f)); } else { sb.append(getString(R.string.no_mount_info)).append('\n'); } sb.append("####################\n"); } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } } if (items[APPLICATIONS]) { sb.append(HEADER_SPLIT); sb.append(getString(R.string.tab_apps) + ":").append('\n'); PackageManager pm = getActivity().getPackageManager(); List<PackageInfo> pkgs = pm.getInstalledPackages(0); if (pkgs != null) { for (int i = 0, size = pkgs.size(); i < size; i++) { PackageInfo pkg = pkgs.get(i); sb.append(pkg.packageName).append(" <") //$NON-NLS-1$ .append(pkg.versionName).append(" (") //$NON-NLS-1$ .append(pkg.versionCode).append(")>"); //$NON-NLS-1$ if (pkg.applicationInfo != null) { sb.append("\t: ") //$NON-NLS-1$ .append(pkg.applicationInfo.loadLabel(pm)).append(" | ") //$NON-NLS-1$ .append(pkg.applicationInfo.flags).append(" | ") //$NON-NLS-1$ .append(pkg.applicationInfo.sourceDir); } sb.append('\n'); } } sb.append("####################\n"); } if (items[PROCESSES]) { sb.append(HEADER_SPLIT); sb.append(getString(R.string.tab_procs) + ":").append('\n'); ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> procs = am.getRunningAppProcesses(); if (procs != null) { PackageManager pm = getActivity().getPackageManager(); for (int i = 0, size = procs.size(); i < size; i++) { RunningAppProcessInfo proc = procs.get(i); sb.append('<').append(getImportance(proc)).append("> [") //$NON-NLS-1$ .append(proc.pid).append("]\t:\t"); //$NON-NLS-1$ sb.append(proc.processName); try { ApplicationInfo ai = pm.getApplicationInfo(proc.processName, 0); if (ai != null) { CharSequence label = pm.getApplicationLabel(ai); if (label != null && !label.equals(proc.processName)) { sb.append(" ( ") //$NON-NLS-1$ .append(label).append(" )"); //$NON-NLS-1$ } } } catch (NameNotFoundException e) { // ignore this error } sb.append('\n'); } } sb.append("####################\n"); } if (items[NETSTATES]) { sb.append(HEADER_SPLIT); sb.append(getString(R.string.tab_netstat) + ":").append('\n'); try { readRawText(sb, new FileInputStream("/proc/net/tcp")); //$NON-NLS-1$ sb.append('\n'); readRawText(sb, new FileInputStream("/proc/net/udp")); //$NON-NLS-1$ } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } sb.append("####################\n"); } if (items[DMESG_LOG]) { sb.append(HEADER_SPLIT); sb.append("Dmesg " + getString(R.string.log) + ":").append('\n'); //$NON-NLS-1$ try { Process proc = Runtime.getRuntime().exec("dmesg"); //$NON-NLS-1$ readRawText(sb, proc.getInputStream()); } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } sb.append("####################\n"); } if (items[LOGCAT_LOG]) { sb.append(HEADER_SPLIT); sb.append("Logcat " + getString(R.string.log) + ":").append('\n'); //$NON-NLS-1$ try { Process proc = Runtime.getRuntime().exec("logcat -d -v time *:V"); //$NON-NLS-1$ readRawText(sb, proc.getInputStream()); } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } sb.append("####################\n"); } return sb.toString(); }
From source file:im.neon.activity.CommonActivityUtils.java
/** * Log the memory statuses.// w w w. j a v a2 s .com * * @param activity the calling activity * @return if the device is running on low memory. */ public static boolean displayMemoryInformation(Activity activity, String title) { long freeSize = 0L; long totalSize = 0L; long usedSize = -1L; try { Runtime info = Runtime.getRuntime(); freeSize = info.freeMemory(); totalSize = info.totalMemory(); usedSize = totalSize - freeSize; } catch (Exception e) { e.printStackTrace(); } Log.e(LOW_MEMORY_LOG_TAG, "---------------------------------------------------"); Log.e(LOW_MEMORY_LOG_TAG, "----------- " + title + " -----------------"); Log.e(LOW_MEMORY_LOG_TAG, "---------------------------------------------------"); Log.e(LOW_MEMORY_LOG_TAG, "usedSize " + (usedSize / 1048576L) + " MB"); Log.e(LOW_MEMORY_LOG_TAG, "freeSize " + (freeSize / 1048576L) + " MB"); Log.e(LOW_MEMORY_LOG_TAG, "totalSize " + (totalSize / 1048576L) + " MB"); Log.e(LOW_MEMORY_LOG_TAG, "---------------------------------------------------"); if (null != activity) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); Log.e(LOW_MEMORY_LOG_TAG, "availMem " + (mi.availMem / 1048576L) + " MB"); Log.e(LOW_MEMORY_LOG_TAG, "totalMem " + (mi.totalMem / 1048576L) + " MB"); Log.e(LOW_MEMORY_LOG_TAG, "threshold " + (mi.threshold / 1048576L) + " MB"); Log.e(LOW_MEMORY_LOG_TAG, "lowMemory " + (mi.lowMemory)); Log.e(LOW_MEMORY_LOG_TAG, "---------------------------------------------------"); return mi.lowMemory; } else { return false; } }
From source file:com.android.mms.transaction.MessagingNotification.java
private static void notifyUserIfFullScreen(Context context, String from) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> runningTasks = am.getRunningTasks(1); if (runningTasks.size() > 0) { String topActivity = runningTasks.get(0).topActivity.getClassName(); Log.d(TAG, "checkIsFullScreenMode: the top activity is: " + topActivity); if ((topActivity != null) && (topActivity.equals("com.android.browser.BrowserActivity"))) { Intent intent = new Intent("com.android.mms.transaction.MESSAGE_RECEIVED"); intent.putExtra("from", from); context.sendBroadcast(intent); }/*w w w.j a v a 2s. c o m*/ } }
From source file:org.uguess.android.sysinfo.SiragonManager.java
String generateHtmlReport(boolean[] items) { StringBuffer sb = new StringBuffer(); createHtmlHeader(getActivity(), sb, escapeHtml("Android System Report - " + new Date().toLocaleString())); //$NON-NLS-1$ if (items[BASIC_INFO]) { sb.append(openHeaderRow).append(getString(R.string.tab_infoCPU)).append(closeHeaderRow); sb.append(openRow).append(getString(R.string.sd_storage)).append(nextColumn4); String[] info = getExternalStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else {//from w ww . j a va 2 s . c o m sb.append(getString(R.string.storage_summary, info[0], info[1])); } sb.append(closeRow); ///////////////////////////UCLIDES////////////////////////// sb.append(openHeaderRow).append(getString(R.string.tab_info)).append(closeHeaderRow); sb.append(openRow).append(getString(R.string.sd_storage)).append(nextColumn4); info = getExternalStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_summary, info[0], info[1])); } sb.append(closeRow); /////////////////////////////////////////////////////////// sb.append(openRow).append(getString(R.string.a2sd_storage)).append(nextColumn4); info = getA2SDStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_summary, info[0], info[1])); } sb.append(closeRow); sb.append(openRow).append(getString(R.string.internal_storage)).append(nextColumn4); info = getInternalStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_summary, info[0], info[1])); } sb.append(closeRow); sb.append(openRow).append(getString(R.string.system_storage)).append(nextColumn4); info = getSystemStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_summary, info[0], info[1])); } sb.append(closeRow); sb.append(openRow).append(getString(R.string.cache_storage)).append(nextColumn4); info = getCacheStorageInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_summary, info[0], info[1])); } sb.append(closeRow); sb.append(openRow).append(getString(R.string.memory)).append(nextColumn4); info = getMemInfo(); if (info == null) { sb.append(getString(R.string.info_not_available)); } else { sb.append(getString(R.string.storage_summary, info[0], info[2]) + getString(R.string.idle_info, info[1])); } sb.append(closeRow); sb.append(openRow).append(getString(R.string.processor)).append(nextColumn4) .append(escapeHtml(getCpuInfo())).append(closeRow); String nInfo = getNetAddressInfo(); sb.append(openRow).append(getString(R.string.net_address)).append(nextColumn4) .append(nInfo == null ? getString(R.string.info_not_available) : nInfo).append(closeRow); sb.append(emptyRow); try { File f = new File(F_SCALE_FREQ); if (f.exists()) { sb.append(openFullRow).append(getString(R.string.sc_freq)); readRawText(sb, new FileInputStream(f)); sb.append(closeRow); } else { sb.append(openFullRow).append(getString(R.string.no_sc_freq_info)).append(closeRow); } sb.append(emptyRow); f = new File(F_CPU_INFO); if (f.exists()) { readRawHTML(sb, new FileInputStream(f)); } else { sb.append(openFullRow).append(getString(R.string.no_cpu_info)).append(closeRow); } sb.append(emptyRow); f = new File(F_MEM_INFO); if (f.exists()) { readRawHTML(sb, new FileInputStream(f)); } else { sb.append(openFullRow).append(getString(R.string.no_mem_info)).append(closeRow); } sb.append(emptyRow); f = new File(F_MOUNT_INFO); if (f.exists()) { readRawHTML(sb, new FileInputStream(f)); } else { sb.append(openFullRow).append(getString(R.string.no_mount_info)).append(closeRow); } sb.append(emptyRow); } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } } if (items[APPLICATIONS]) { sb.append(openHeaderRow).append(getString(R.string.tab_apps)).append(closeHeaderRow); sb.append(openTitleRow).append("<b>") //$NON-NLS-1$ .append(getString(R.string.pkg_name)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.version)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.app_label)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.flags)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.source)).append("</b>") //$NON-NLS-1$ .append(closeRow); PackageManager pm = getActivity().getPackageManager(); List<PackageInfo> pkgs = pm.getInstalledPackages(0); if (pkgs != null) { for (int i = 0, size = pkgs.size(); i < size; i++) { PackageInfo pkg = pkgs.get(i); sb.append(openRow).append(escapeHtml(pkg.packageName)).append(nextColumn) .append(escapeHtml(pkg.versionName)).append(" (") //$NON-NLS-1$ .append(pkg.versionCode).append(')'); if (pkg.applicationInfo != null) { sb.append(nextColumn).append(escapeHtml(pkg.applicationInfo.loadLabel(pm).toString())) .append(nextColumn).append(pkg.applicationInfo.flags).append(nextColumn) .append(escapeHtml(pkg.applicationInfo.sourceDir)); } sb.append(closeRow); } } sb.append(emptyRow); } if (items[PROCESSES]) { sb.append(openHeaderRow).append(getString(R.string.tab_procs)).append(closeHeaderRow); sb.append(openTitleRow).append("<b>") //$NON-NLS-1$ .append(getString(R.string.importance)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.pid)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.proc_name)).append("</b>") //$NON-NLS-1$ .append(nextColumn).append("<b>") //$NON-NLS-1$ .append(getString(R.string.app_label)).append("</b>") //$NON-NLS-1$ .append(closeRow); ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> procs = am.getRunningAppProcesses(); if (procs != null) { PackageManager pm = getActivity().getPackageManager(); for (int i = 0, size = procs.size(); i < size; i++) { RunningAppProcessInfo proc = procs.get(i); sb.append(openRow).append(getImportance(proc)).append(nextColumn).append(proc.pid) .append(nextColumn).append(escapeHtml(proc.processName)); try { ApplicationInfo ai = pm.getApplicationInfo(proc.processName, 0); if (ai != null) { CharSequence label = pm.getApplicationLabel(ai); if (label != null && !label.equals(proc.processName)) { sb.append(nextColumn).append(escapeHtml(label.toString())); } } } catch (NameNotFoundException e) { // ignore this error } sb.append(closeRow); } } sb.append(emptyRow); } if (items[NETSTATES]) { sb.append(openHeaderRow).append(getString(R.string.tab_netstat)).append(closeHeaderRow); try { readRawHTML(sb, new FileInputStream("/proc/net/tcp")); //$NON-NLS-1$ sb.append(emptyRow); readRawHTML(sb, new FileInputStream("/proc/net/udp")); //$NON-NLS-1$ } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } sb.append(emptyRow); } if (items[DMESG_LOG]) { sb.append(openHeaderRow).append("Dmesg " //$NON-NLS-1$ + getString(R.string.log)).append(closeHeaderRow); try { Process proc = Runtime.getRuntime().exec("dmesg"); //$NON-NLS-1$ readRawHTML(sb, proc.getInputStream()); } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } sb.append(emptyRow); } if (items[LOGCAT_LOG]) { sb.append(openHeaderRow).append("Logcat " //$NON-NLS-1$ + getString(R.string.log)).append(closeHeaderRow); try { Process proc = Runtime.getRuntime().exec("logcat -d -v time *:V"); //$NON-NLS-1$ readRawHTML(sb, proc.getInputStream()); } catch (Exception e) { Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e); } sb.append(emptyRow); } sb.append("</table></font></body></html>"); //$NON-NLS-1$ return sb.toString(); }
From source file:com.miz.functions.MizLib.java
public static boolean isMovieLibraryBeingUpdated(Context c) { ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE); int count = services.size(); for (int i = 0; i < count; i++) { if (MovieLibraryUpdate.class.getName().equals(services.get(i).service.getClassName())) { return true; }//from w w w. j a v a 2 s . c o m } return false; }
From source file:com.miz.functions.MizLib.java
public static boolean isTvShowLibraryBeingUpdated(Context c) { ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE); int count = services.size(); for (int i = 0; i < count; i++) { if (TvShowsLibraryUpdate.class.getName().equals(services.get(i).service.getClassName())) { return true; }//from w ww. j a v a2s. c o m } return false; }