List of usage examples for android.util Log i
public static int i(String tag, String msg)
From source file:Main.java
public static BufferedReader getCheatsLocation(String regularExpression, String filename) { // Make sure a file was specified in the constructor if (TextUtils.isEmpty(filename)) { Log.e("CheatFile", "Filename not specified in method reload()"); return null; }/* w w w.ja v a2 s.co m*/ BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(filename)); boolean done = false; String fullLine = null; while (!done && (fullLine = reader.readLine()) != null) { if (fullLine.startsWith("crc ")) { // Start of the next cheat section, return done = fullLine.substring(4).matches(regularExpression); } } if (fullLine != null) { Log.i("CheatUtils", fullLine); } } catch (FileNotFoundException e) { Log.e("CheatFile", "Could not open " + filename); return null; } catch (IOException e) { Log.e("CheatFile", "Could not read " + filename); return null; } return reader; }
From source file:Main.java
public static String httpStringGet(String url, String enc) throws Exception { // This method for HttpConnection String page = ""; BufferedReader bufferedReader = null; try {/*from ww w . j ava2s . co m*/ HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "android"); HttpParams httpParams = client.getParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 3000); HttpConnectionParams.setSoTimeout(httpParams, 5000); HttpGet request = new HttpGet(); request.setHeader("Content-Type", "text/plain; charset=utf-8"); request.setURI(new URI(url)); HttpResponse response = client.execute(request); bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), enc)); StringBuffer stringBuffer = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator");// "\n" while ((line = bufferedReader.readLine()) != null) { stringBuffer.append(line + NL); } bufferedReader.close(); page = stringBuffer.toString(); Log.i("page", page); System.out.println(page + "page"); return page; } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { Log.d("BBB", e.toString()); } } } }
From source file:com.nxp.ltsm.ltsmclient.tools.VCDescriptionFile.java
public static byte[] createF8Vc(String appName, short vcEntry, byte[] mfdfaid, byte[] cltecap) { String TAG = "VCDescriptionFile:createVC"; Log.i(TAG, "Enter"); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] apkId = null; try {/* www . ja v a 2 s .c o m*/ apkId = Hex.decodeHex(appName.toCharArray()); } catch (DecoderException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return null; } try { out.write(TLV.createTLV(0x4F, apkId)); out.write(TLV.createTLV(0x40, new byte[] { (byte) (vcEntry >> 8), (byte) (vcEntry) })); out.write(TLV.createTLV(0xF8, mfdfaid)); out.write(TLV.createTLV(0xE2, cltecap)); return TLV.createTLV(0x74, out.toByteArray()); } catch (IOException e) { e.printStackTrace(); System.exit(1); return null; } }
From source file:Main.java
/** * Create a account for the sync adapter. * * @param _context The application context. * @return the new created Account./*from ww w . ja v a 2s . c om*/ */ public static Account createSyncAccount(Context _context, String _username) { // create a new a account. Account newAccount = new Account(_username, ACCOUNT_TYPE); AccountManager accountManager = (AccountManager) _context.getSystemService(Context.ACCOUNT_SERVICE); Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); for (Account account : accounts) { if (account.equals(newAccount)) { // account already exists return null; } } // try to login and retrieve the token Bundle bundle = new Bundle(); bundle.putString("Token", "some auth token please"); if (accountManager.addAccountExplicitly(newAccount, null, bundle)) { } else { Log.i(TAG, "createSyncAccount: account already exists or an error happened"); } return newAccount; }
From source file:Main.java
public static Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes(); if (rawSupportedSizes == null) { Log.w(TAG, "Device returned no supported preview sizes; using default"); Camera.Size defaultSize = parameters.getPreviewSize(); if (defaultSize == null) { throw new IllegalStateException("Parameters contained no preview size!"); }//from w w w . ja va 2 s . c o m return new Point(defaultSize.width, defaultSize.height); } if (Log.isLoggable(TAG, Log.INFO)) { StringBuilder previewSizesString = new StringBuilder(); for (Camera.Size size : rawSupportedSizes) { previewSizesString.append(size.width).append('x').append(size.height).append(' '); } Log.i(TAG, "Supported preview sizes: " + previewSizesString); } double screenAspectRatio = screenResolution.x / (double) screenResolution.y; // Find a suitable size, with max resolution int maxResolution = 0; Camera.Size maxResPreviewSize = null; for (Camera.Size size : rawSupportedSizes) { int realWidth = size.width; int realHeight = size.height; int resolution = realWidth * realHeight; if (resolution < MIN_PREVIEW_PIXELS) { continue; } boolean isCandidatePortrait = realWidth < realHeight; int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; double aspectRatio = maybeFlippedWidth / (double) maybeFlippedHeight; double distortion = Math.abs(aspectRatio - screenAspectRatio); if (distortion > MAX_ASPECT_DISTORTION) { continue; } if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { Point exactPoint = new Point(realWidth, realHeight); Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); return exactPoint; } // Resolution is suitable; record the one with max resolution if (resolution > maxResolution) { maxResolution = resolution; maxResPreviewSize = size; } } // If no exact match, use largest preview size. This was not a great idea on older devices because // of the additional computation needed. We're likely to get here on newer Android 4+ devices, where // the CPU is much more powerful. if (maxResPreviewSize != null) { Point largestSize = new Point(maxResPreviewSize.width, maxResPreviewSize.height); Log.i(TAG, "Using largest suitable preview size: " + largestSize); return largestSize; } // If there is nothing at all suitable, return current preview size Camera.Size defaultPreview = parameters.getPreviewSize(); if (defaultPreview == null) { throw new IllegalStateException("Parameters contained no preview size!"); } Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); return defaultSize; }
From source file:com.isec.helperapp.EasySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { Log.i(TAG, "createEasySSLContext"); try {//from w w w .j ava 2 s . c o m SSLContext context = SSLContext.getInstance("TLS"); context.init(null, TrustAllTrustManager.getTrustManagers(), null); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:edu.umich.flowfence.testapp.TestQM.java
private static void trace(String method, Object... args) { //Log.i(TAG, String.format("%s()", method)); Log.i(TAG, String.format("%s(%s)", method, StringUtils.join(args, ", "))); }
From source file:com.microsoft.azure.engagement.unity.EngagementWrapper.java
public static void handleOpenURL(String _url) { Log.i(EngagementShared.LOG_TAG, "handleOpenURL: " + _url); openURL = _url; }
From source file:Main.java
public static File getExternalCacheDir(Context context, String dirName) { File dataDir = new File(new File(Environment.getExternalStorageDirectory(), "Charismatic_yichang"), "data"); File appCacheDir2 = new File(new File(dataDir, context.getPackageName()), "cache"); File appCacheDir = new File(appCacheDir2, dirName); if (!appCacheDir.exists()) { if (!appCacheDir.mkdirs()) { Log.w(TAG, "Unable to create external cache directory"); return null; }/*from w w w . j a v a 2s.c o m*/ try { new File(appCacheDir, ".nomedia").createNewFile(); } catch (IOException e) { Log.i(TAG, "Can't create \".nomedia\" file in application external cache directory"); } } return appCacheDir; }
From source file:net.reichholf.dreamdroid.intents.IntentFactory.java
public static Intent getStreamServiceIntent(String ref, String title) { Intent intent = new Intent(Intent.ACTION_VIEW); String uriString = SimpleHttpClient.getInstance().buildServiceStreamUrl(ref, title); Log.i(DreamDroid.LOG_TAG, "Service-Streaming URL set to '" + uriString + "'"); intent.setDataAndType(Uri.parse(uriString), "video/*"); intent.putExtra("title", title); return intent; }