List of usage examples for android.util Log i
public static int i(String tag, String msg)
From source file:Main.java
public static void log(String tag, String value) { Log.i(tag, value); }
From source file:Main.java
public static String runCommand(String[] commands) { DataOutputStream outStream = null; DataInputStream responseStream; try {/*ww w. j a va2 s. c o m*/ ArrayList<String> logs = new ArrayList<String>(); Process process = Runtime.getRuntime().exec("su"); Log.i(TAG, "Executed su"); outStream = new DataOutputStream(process.getOutputStream()); responseStream = new DataInputStream(process.getInputStream()); for (String single : commands) { Log.i(TAG, "Command = " + single); outStream.writeBytes(single + "\n"); outStream.flush(); if (responseStream.available() > 0) { Log.i(TAG, "Reading response"); logs.add(responseStream.readLine()); Log.i(TAG, "Read response"); } else { Log.i(TAG, "No response available"); } } outStream.writeBytes("exit\n"); outStream.flush(); String log = ""; for (int i = 0; i < logs.size(); i++) { log += logs.get(i) + "\n"; } Log.i(TAG, "Execution compeleted"); return log; } catch (IOException e) { Log.d(TAG, e.getMessage()); } return null; }
From source file:Main.java
public static String getRequestUrl(String id, String secret, String com, String number, String encode) { StringBuffer resultUrl = new StringBuffer(); resultUrl.append("http://api.ickd.cn/?id=" + (id != null ? id : xfid)); resultUrl.append("&secret=" + (secret != null ? secret : xfsecret)); resultUrl.append("&com=" + com); resultUrl.append("&nu=" + number); resultUrl.append("&encode=" + (encode != null ? encode : "gbk") + "&ord=asc"); Log.i(TAG, "Request URL:" + resultUrl); return resultUrl.toString(); }
From source file:Main.java
/** * @brief log utility// ww w . j ava 2s .c om */ static private void log(String format, Object arg1) { if (enableLog) Log.i(TAG, String.format(format, arg1)); }
From source file:Main.java
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. *///from ww w .j a va 2 s . co m public static File getOutputMediaFile(File myDir) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. Log.i("CameraSample", "about to check state of external storage"); if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { Log.d("CameraSample", "externalstoragestate was " + Environment.getExternalStorageState()); return null; } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile = new File(myDir + File.separator + "VID_" + timeStamp + ".mp4"); return mediaFile; }
From source file:Main.java
public static boolean isMainProcess(Context context) { String currentProcessName = getCurProcessName(context); if (TextUtils.isEmpty(currentProcessName)) { return false; }// ww w. j ava 2s. com String mainPrcocessName = getMainProcessName(context); final String packageName = context.getPackageName(); Log.i("WxUtil", "current process name:" + currentProcessName + "---main process name:" + mainPrcocessName); return currentProcessName.equals(mainPrcocessName) || currentProcessName.equals(packageName); }
From source file:Main.java
public static Cursor getAllCallLogAboutACaller(Context context, String callerNumber) { // cancello la chiamata in uscita se nelle preferenze ? settata tale opzione Uri delUri = Uri.withAppendedPath(CallLog.Calls.CONTENT_URI, ""); Cursor cursor = context.getContentResolver().query(delUri, null, android.provider.CallLog.Calls.NUMBER + "=?", new String[] { "404" }, null); try {// w ww .ja v a 2 s. com boolean moveToFirst = cursor.moveToFirst(); Log.i("MOVETOFIRST", "moveToFirst=" + moveToFirst); do { int numberColumn = cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER); String callerPhoneNumber = cursor.getString(numberColumn); Log.i(TAG, "numero : " + callerPhoneNumber); } while (cursor.moveToNext()); } catch (Exception e) { Log.e(TAG, "Problem moving to first entry", e); } return cursor; }
From source file:Main.java
/*** * Extract zipfile to outdir with complete directory structure * @param zipfile Input .zip file// w ww. j a va2 s .co m * @param outdir Output directory */ public static void extract(InputStream zipfile, File outdir) { try { ZipInputStream zin = new ZipInputStream(zipfile); ZipEntry entry; String name, dir; Log.i("OF", "uncompressinggggg "); while ((entry = zin.getNextEntry()) != null) { name = entry.getName(); if (entry.isDirectory()) { mkdirs(outdir, name); continue; } dir = dirpart(name); if (dir != null) mkdirs(outdir, dir); extractFile(zin, outdir, name); } zin.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Detects and toggles immersive mode (also known as "hidey bar" mode). *//*from ww w . j ava2s . co m*/ public static void toggleHideyBar(Window window, String TAG) { // The UI options currently enabled are represented by a bitfield. // getSystemUiVisibility() gives us that bitfield. int uiOptions = window.getDecorView().getSystemUiVisibility(); int newUiOptions = uiOptions; boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions); if (isImmersiveModeEnabled) { Log.i(TAG, "Turning immersive mode mode off. "); } else { Log.i(TAG, "Turning immersive mode mode on."); } // Navigation bar hiding: Backwards compatible to ICS. if (Build.VERSION.SDK_INT >= 14) { newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } // Status bar hiding: Backwards compatible to Jellybean if (Build.VERSION.SDK_INT >= 16) { newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; } // Immersive mode: Backward compatible to KitKat. // Note that this flag doesn't do anything by itself, it only augments the behavior // of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample // all three flags are being toggled together. // Note that there are two immersive mode UI flags, one of which is referred to as "sticky". // Sticky immersive mode differs in that it makes the navigation and status bars // semi-transparent, and the UI flag does not get cleared when the user interacts with // the screen. if (Build.VERSION.SDK_INT >= 18) { newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } window.getDecorView().setSystemUiVisibility(newUiOptions); }
From source file:Main.java
/** * Sarches for ressources that have to be downloaded and creates a list with all download links. * * @param node to check for download links * @return list with all found download links *//*w ww .j a v a2 s. c om*/ private static ArrayList<String> findUrls(Node node) { int type = node.getNodeType(); ArrayList<String> result = new ArrayList<>(); String temp = null; NamedNodeMap atts = node.getAttributes(); Log.i(TAG, "parsing for ressources. node: " + node.getNodeName() + " value: " + node.getNodeValue() + " atts length: " + atts.getLength() + "type: " + type); switch (type) { //Element case Node.ELEMENT_NODE: //TODO: This method is stupid. It just looks for // attributes named ressourcepath. What if we have to download several ressources? for (int j = 0; j < atts.getLength(); j++) { Log.i(TAG, "atts: " + atts.item(j).getNodeName() + " value: " + atts.item(j).getNodeValue()); temp = atts.item(j).getNodeValue(); if (temp != null) { result.add(temp); Log.i(TAG, "added path: " + temp); } Log.i(TAG, "parent node:" + node.getParentNode().getNodeName()); Element parent = (Element) node.getParentNode(); parent.setAttribute("TESTITEST", "dllink"); } // get the pages, means the children for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { ArrayList<String> childres = findUrls(child); if (childres.size() > 0) { result.addAll(childres); } } break; } return result; }