List of usage examples for android.util Log wtf
public static int wtf(String tag, String msg, Throwable tr)
From source file:com.google.android.gms.common.GooglePlayServicesUtilLight.java
private static void zzao(Context context) { if (!zzaqb.get()) { Integer num;/*from w w w .jav a 2 s. c om*/ synchronized (zzrc) { if (zzapY == null) { zzapY = context.getPackageName(); try { Bundle bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData; if (bundle != null) { zzapZ = Integer.valueOf(bundle.getInt("com.google.android.gms.version")); } else { zzapZ = null; } } catch (Throwable e) { Log.wtf("GooglePlayServicesUtil", "This should never happen.", e); } } else if (!zzapY.equals(context.getPackageName())) { throw new IllegalArgumentException( "isGooglePlayServicesAvailable should only be called with Context from your application's package. A previous call used package '" + zzapY + "' and this call used package '" + context.getPackageName() + "'."); } num = zzapZ; } if (num == null) { throw new IllegalStateException( "A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name=\"com.google.android.gms.version\" android:value=\"@integer/google_play_services_version\" />"); } else if (num.intValue() != GOOGLE_PLAY_SERVICES_VERSION_CODE) { throw new IllegalStateException( "The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected " + GOOGLE_PLAY_SERVICES_VERSION_CODE + " but" + " found " + num + ". You must have the" + " following declaration within the <application> element: " + " <meta-data android:name=\"" + "com.google.android.gms.version" + "\" android:value=\"@integer/google_play_services_version\" />"); } } }
From source file:com.robandjen.comicsapp.FullscreenActivity.java
private void loadDefaultXML() { InputStream is;/* www. j a v a2 s . c o m*/ try { is = getAssets().open(COMICFILE); loadXml(is); } catch (IOException e) { Log.wtf(TAG, "Exception loading default XML", e); } }
From source file:com.github.jobs.ui.activity.EditTemplateActivity.java
private boolean addTemplateService(TemplateService service) { EditTemplateFragment fragment = findFragment(EditTemplateFragment.class); if (fragment == null) { Log.wtf(TAG, "Fragment shall not be null here", new RuntimeException()); return false; }/*from w w w .j a va 2 s.c om*/ fragment.addTemplateService(service); // since we added a template service, show the remove action button mMenuRemoveService.setVisible(true); return true; }
From source file:com.pixmob.r2droid.DeviceRegistrationService.java
private void onC2DMUnregistered() { final String regId = Preferences.getRegistrationId(getApplicationContext()); if (DEV) {//from ww w . ja v a2 s . c o m Log.i(TAG, "Device unregistered from C2DM"); } int event = DISCONNECTED_EVENT; String error = null; try { final String url = "https://r2droidhq.appspot.com/api/1/unregister?regid=" + urlEncode(regId); if (DEV) { Log.d(TAG, "Unregister URL: " + url); } final HttpGet req = new HttpGet(url); if (!configureClient()) { event = CONNECTED_EVENT; error = AUTH_FAILED_ERROR; } else { final int statusCode = gaeClient.execute(req).getStatusLine().getStatusCode(); if (statusCode == HTTP_SC_OK) { Preferences.setAccount(getApplicationContext(), null); } else { if (DEV) { Log.w(TAG, "Failed to unregister device: statusCode=" + statusCode); } event = CONNECTED_EVENT; error = DEVICE_UNREGISTRATION_ERROR; } } } catch (AppEngineAuthenticationException e) { if (e.isAuthenticationPending()) { if (DEV) { Log.i(TAG, "User must give permission to use authentication token: " + "unregistration aborted", e); } event = CONNECTED_EVENT; error = AUTH_PENDING; } else { if (DEV) { Log.w(TAG, "Authentication error", e); } event = CONNECTED_EVENT; error = AUTH_FAILED_ERROR; } } catch (IOException e) { if (DEV) { Log.w(TAG, "Network error", e); } event = CONNECTED_EVENT; error = NETWORK_ERROR; } catch (Exception e) { Log.wtf(TAG, "Unexpected error", e); event = CONNECTED_EVENT; error = DEVICE_UNREGISTRATION_ERROR; } fireEvent(event, error); int ticketRes = R.string.device_is_offline; if (event != DISCONNECTED_EVENT) { ticketRes = R.string.updating_device_failed; } final Notification notification = new Notification(R.drawable.ic_stat_icon, getString(ticketRes), System.currentTimeMillis()); notification.setLatestEventInfo(this, getString(R.string.app_name), getString(ticketRes), dashboardIntent); nm.notify(STATUS_UPDATE_DONE, notification); }
From source file:com.pixmob.r2droid.DeviceRegistrationService.java
private static String urlEncode(String str) { String encoded = str;//from www . j av a2 s. c om try { encoded = URLEncoder.encode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.wtf(TAG, "UTF-8 encoding is unavailable", e); } return encoded; }
From source file:de.jadehs.jadehsnavigator.fragment.VorlesungsplanFragment.java
public void getCustomVPlan() { try {// ww w. j av a 2 s. c o m // Datenquelle ffnen und Eintrge aufrufen this.custom_vplan_datasource = new CustomVPlanDataSource(getActivity().getApplicationContext()); this.custom_vplan_datasource.open(); ArrayList<VPlanItem> vPlanItems = this.custom_vplan_datasource.getAllCustomVPlanItems(); Collections.sort(vPlanItems, new Comparator<VPlanItem>() { @Override public int compare(VPlanItem lhs, VPlanItem rhs) { return lhs.getStartTime().compareTo(rhs.getStartTime()); } }); if (!vPlanItems.isEmpty()) { VPlanPagerAdapter vPlanPagerAdapter = new VPlanPagerAdapter(getActivity(), vPlanItems, this.weekOfYear); vPlanPagerAdapter.setIsCustomVPlanShown(true); viewpager = (ViewPager) getActivity().findViewById(R.id.vplan_viewpager); viewpager.setAdapter(vPlanPagerAdapter); viewpager.setCurrentItem(calendarHelper.getDay()); vPlanTabLayout = (VPlanTabLayout) getActivity().findViewById(R.id.vplan_sliding_tabs); vPlanTabLayout.setmViewPager(viewpager); this.custom_vplan_datasource.close(); } else getActivity().findViewById(R.id.empty_custom_vplan).setVisibility(View.VISIBLE); } catch (Exception e) { e.printStackTrace(); } if (!this.preferences.getBoolean("custom_vplan_instructions_read", false)) { try { this.preferences.save("custom_vplan_instructions_read", true); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage( "Durch einen langen Klick kannst du eine Vorlesung aus deinem Vorlesungsplan entfernen.") .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); } catch (Exception ex) { Log.wtf("EXXX", "EX", ex); } } //getActivity().findViewById(R.id.vplan_semester).setVisibility(View.GONE); getActivity().findViewById(R.id.progressVPlan).setVisibility(View.GONE); }
From source file:org.skt.runtime.html5apis.file.FileTransfer.java
/** * Uploads the specified file to the server URL provided using an HTTP multipart request. * @param source Full path of the file on the file system * @param target URL of the server to receive the file * @param args JSON Array of args * * args[2] fileKey Name of file request parameter * args[3] fileName File name to be used on server * args[4] mimeType Describes file content type * args[5] params key:value pairs of user-defined parameters * @return FileUploadResult containing result of upload request *///from www .j av a 2 s . c o m private PluginResult upload(String source, String target, JSONArray args) { Log.d(LOG_TAG, "upload " + source + " to " + target); HttpURLConnection conn = null; try { // Setup the options String fileKey = getArgument(args, 2, "file"); String fileName = getArgument(args, 3, "image.jpg"); String mimeType = getArgument(args, 4, "image/jpeg"); JSONObject params = args.optJSONObject(5); if (params == null) { params = new JSONObject(); } boolean trustEveryone = args.optBoolean(6); boolean chunkedMode = args.optBoolean(7) || args.isNull(7); //Always use chunked mode unless set to false as per API Log.d(LOG_TAG, "fileKey: " + fileKey); Log.d(LOG_TAG, "fileName: " + fileName); Log.d(LOG_TAG, "mimeType: " + mimeType); Log.d(LOG_TAG, "params: " + params); Log.d(LOG_TAG, "trustEveryone: " + trustEveryone); Log.d(LOG_TAG, "chunkedMode: " + chunkedMode); // Create return object FileUploadResult result = new FileUploadResult(); // Get a input stream of the file on the phone FileInputStream fileInputStream = (FileInputStream) getPathFromUri(source); DataOutputStream dos = null; int bytesRead, bytesAvailable, bufferSize; long totalBytes; byte[] buffer; int maxBufferSize = 8096; //------------------ CLIENT REQUEST // open a URL connection to the server URL url = new URL(target); // Open a HTTP connection to the URL based on protocol if (url.getProtocol().toLowerCase().equals("https")) { // Using standard HTTPS connection. Will not allow self signed certificate if (!trustEveryone) { conn = (HttpsURLConnection) url.openConnection(); } // Use our HTTPS connection that blindly trusts everyone. // This should only be used in debug environments else { // Setup the HTTPS connection class to trust everyone trustAllHosts(); HttpsURLConnection https = (HttpsURLConnection) url.openConnection(); // Save the current hostnameVerifier defaultHostnameVerifier = https.getHostnameVerifier(); // Setup the connection not to verify hostnames https.setHostnameVerifier(DO_NOT_VERIFY); conn = https; } } // Return a standard HTTP connection else { conn = (HttpURLConnection) url.openConnection(); } // Allow Inputs conn.setDoInput(true); // Allow Outputs conn.setDoOutput(true); // Don't use a cached copy. conn.setUseCaches(false); // Use a post method. conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY); // Handle the other headers try { JSONObject headers = params.getJSONObject("headers"); for (Iterator iter = headers.keys(); iter.hasNext();) { String headerKey = iter.next().toString(); conn.setRequestProperty(headerKey, headers.getString(headerKey)); } } catch (JSONException e1) { // No headers to be manipulated! } // Set the cookies on the response String cookie = CookieManager.getInstance().getCookie(target); if (cookie != null) { conn.setRequestProperty("Cookie", cookie); } /* * Store the non-file portions of the multipart data as a string, so that we can add it * to the contentSize, since it is part of the body of the HTTP request. */ String extraParams = ""; try { for (Iterator iter = params.keys(); iter.hasNext();) { Object key = iter.next(); if (!String.valueOf(key).equals("headers")) { extraParams += LINE_START + BOUNDARY + LINE_END; extraParams += "Content-Disposition: form-data; name=\"" + key.toString() + "\";"; extraParams += LINE_END + LINE_END; extraParams += params.getString(key.toString()); extraParams += LINE_END; } } } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); } extraParams += LINE_START + BOUNDARY + LINE_END; extraParams += "Content-Disposition: form-data; name=\"" + fileKey + "\";" + " filename=\""; String midParams = "\"" + LINE_END + "Content-Type: " + mimeType + LINE_END + LINE_END; String tailParams = LINE_END + LINE_START + BOUNDARY + LINE_START + LINE_END; // Should set this up as an option if (chunkedMode) { conn.setChunkedStreamingMode(maxBufferSize); } else { int stringLength = extraParams.getBytes("UTF-8").length + midParams.getBytes("UTF-8").length + tailParams.getBytes("UTF-8").length + fileName.getBytes("UTF-8").length; Log.d(LOG_TAG, "String Length: " + stringLength); int fixedLength = (int) fileInputStream.getChannel().size() + stringLength; Log.d(LOG_TAG, "Content Length: " + fixedLength); conn.setFixedLengthStreamingMode(fixedLength); } dos = new DataOutputStream(conn.getOutputStream()); dos.write(extraParams.getBytes("UTF-8")); //We don't want to chagne encoding, we just want this to write for all Unicode. dos.write(fileName.getBytes("UTF-8")); dos.write(midParams.getBytes("UTF-8")); // create a buffer of maximum size bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); buffer = new byte[bufferSize]; // read file and write it into form... bytesRead = fileInputStream.read(buffer, 0, bufferSize); totalBytes = 0; while (bytesRead > 0) { totalBytes += bytesRead; result.setBytesSent(totalBytes); dos.write(buffer, 0, bufferSize); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); } // send multipart form data necesssary after file data... dos.write(tailParams.getBytes("UTF-8")); // close streams fileInputStream.close(); dos.flush(); dos.close(); //------------------ read the SERVER RESPONSE StringBuffer responseString = new StringBuffer(""); DataInputStream inStream; try { inStream = new DataInputStream(conn.getInputStream()); } catch (FileNotFoundException e) { Log.e(LOG_TAG, e.toString(), e); throw new IOException("Received error from server"); } String line; while ((line = inStream.readLine()) != null) { responseString.append(line); } Log.d(LOG_TAG, "got response from server"); Log.d(LOG_TAG, responseString.toString()); // send request and retrieve response result.setResponseCode(conn.getResponseCode()); result.setResponse(responseString.toString()); inStream.close(); // Revert back to the proper verifier and socket factories if (trustEveryone && url.getProtocol().toLowerCase().equals("https")) { ((HttpsURLConnection) conn).setHostnameVerifier(defaultHostnameVerifier); HttpsURLConnection.setDefaultSSLSocketFactory(defaultSSLSocketFactory); } Log.d(LOG_TAG, "****** About to return a result from upload"); return new PluginResult(PluginResult.Status.OK, result.toJSONObject()); } catch (FileNotFoundException e) { JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, conn); Log.e(LOG_TAG, error.toString(), e); return new PluginResult(PluginResult.Status.IO_EXCEPTION, error); } catch (MalformedURLException e) { JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target, conn); Log.e(LOG_TAG, error.toString(), e); return new PluginResult(PluginResult.Status.IO_EXCEPTION, error); } catch (IOException e) { JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn); Log.e(LOG_TAG, error.toString(), e); return new PluginResult(PluginResult.Status.IO_EXCEPTION, error); } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } catch (Throwable t) { // Shouldn't happen, but will JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn); Log.wtf(LOG_TAG, error.toString(), t); return new PluginResult(PluginResult.Status.IO_EXCEPTION, error); } finally { if (conn != null) { conn.disconnect(); } } }
From source file:de.unipassau.isl.evs.ssh.app.activity.AppMainActivity.java
/** * Displays a fragment and takes care of lifecycle actions like saving state when rotating the * screen or managing the back button behavior. * * @param clazz the class of the fragment to show * @param bundle the bundle that is given with the new fragment *///w w w . j av a 2 s .com public void showFragmentByClass(Class clazz, Bundle bundle) { Class classToShow = clazz; final boolean isRegistered = isRegistered(); final Permission permission = permissionForFragment.get(classToShow); if (permission != null && !hasPermission(permission) && isRegistered) { Toast.makeText(this, String.format(getString(R.string.fragment_access_denied), permission.toLocalizedString(this)), Toast.LENGTH_SHORT).show(); return; } final Fragment currentFragment = getCurrentFragment(); if (currentFragment != null && Objects.equals(classToShow, currentFragment.getClass())) { return; } // avoid leaving the welcome fragment before registration if (!isRegistered) { classToShow = WelcomeScreenFragment.class; } final Fragment fragment; try { fragment = (Fragment) classToShow.newInstance(); if (bundle != null) { fragment.setArguments(bundle); } } catch (InstantiationException | IllegalAccessException e) { Log.wtf(TAG, "Could not instantiate fragment", e); return; } // Hide Keyboard before every fragment transaction View view = getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, fragment); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (currentFragment instanceof MainFragment && fragment instanceof HolidayFragment) { View fragmentView = currentFragment.getView(); if (fragmentView != null) { transaction.addSharedElement(fragmentView.findViewById(R.id.holidayButton), "holidayIconTransition"); } final TransitionInflater inflater = TransitionInflater.from(this); currentFragment.setSharedElementReturnTransition( inflater.inflateTransition(R.transition.change_image_trans)); currentFragment.setExitTransition(inflater.inflateTransition(android.R.transition.explode)); fragment.setSharedElementEnterTransition( inflater.inflateTransition(R.transition.change_image_trans)); fragment.setEnterTransition(inflater.inflateTransition(android.R.transition.explode)); } else if (fragment instanceof MainFragment && currentFragment != null) { transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); } else { transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); } } transaction.commit(); }
From source file:com.google.android.gcm.demo.ui.MainActivity.java
private void selectItem(int pos) { if (pos < 0 || pos >= mMainMenu.getEntries().length) { pos = 0;// w w w . j a v a 2 s .c o m } String titlePrefix = getString(R.string.main_activity_title_prefix); getSupportActionBar().setTitle(titlePrefix + mMainMenu.getEntries()[pos]); String nextFragmentTag = "FRAGMENT_TAG_" + Integer.toString(pos); Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container); if (currentFragment != null && nextFragmentTag.equals(currentFragment.getTag())) { return; } Fragment recycledFragment = getSupportFragmentManager().findFragmentByTag(nextFragmentTag); try { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (currentFragment != null) { transaction.detach(currentFragment); } if (recycledFragment != null) { transaction.attach(recycledFragment); } else { transaction.add(R.id.container, mMainMenu.createFragment(pos), nextFragmentTag); } transaction.commit(); getSupportFragmentManager().executePendingTransactions(); // The header takes the first position. mDrawerMenu.setItemChecked(pos + 1, true); getAppPreferences().edit().putInt(PREF_LAST_SCREEN_ID, pos).apply(); } catch (InstantiationException e) { Log.wtf(LoggingService.LOG_TAG, "Error while instantiating the selected fragment", e); } catch (IllegalAccessException e) { Log.wtf(LoggingService.LOG_TAG, "Error while instantiating the selected fragment", e); } }
From source file:edu.stanford.mobisocial.dungbeetle.MessagingManagerThread.java
@Override public void run() { ProfileScanningObjHandler profileScanningObjHandler = new ProfileScanningObjHandler(); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Set<Long> notSendingObjects = new HashSet<Long>(); if (DBG)/*from w w w .jav a 2 s . c om*/ Log.i(TAG, "Running..."); mMessenger.init(); long max_sent = -1; while (!interrupted()) { mOco.waitForChange(); mOco.clearChanged(); Cursor objs = mHelper.queryUnsentObjects(max_sent); try { Log.i(TAG, "Sending " + objs.getCount() + " objects..."); if (objs.moveToFirst()) do { Long objId = objs.getLong(objs.getColumnIndexOrThrow(DbObject._ID)); String jsonSrc = objs.getString(objs.getColumnIndexOrThrow(DbObject.JSON)); max_sent = objId.longValue(); JSONObject json = null; if (jsonSrc != null) { try { json = new JSONObject(jsonSrc); } catch (JSONException e) { Log.e(TAG, "bad json", e); } } else { json = new JSONObject(); } if (json != null) { /* * if you update latest feed here then there is a * race condition between when you put a message * into your db, when you actually have a connection * to send the message (which is here) when other * people send you messages the processing gets all * out of order, so instead we update latest * immediately when you add messages into your db * inside DBHelper.java addToFeed(); */ // mFeedModifiedObjHandler.handleObj(mContext, // feedUri, objId); // TODO: Don't be fooled! This is not truly an // EncodedObj // and does not yet have a hash. DbObj signedObj = App.instance().getMusubi().objForId(objId); if (signedObj == null) { Log.e(TAG, "Error, object " + objId + " not found in database"); notSendingObjects.add(objId); continue; } DbEntryHandler h = DbObjects.getObjHandler(json); h.afterDbInsertion(mContext, signedObj); // TODO: Constraint error thrown for now b/c local // user not in contacts profileScanningObjHandler.handleObj(mContext, h, signedObj); } OutgoingMessage m = new OutgoingMsg(objs); if (m.contents().getRecipients().isEmpty()) { Log.w(TAG, "No addressees for direct message " + objId); notSendingObjects.add(objId); } else { mMessenger.sendMessage(m); } } while (objs.moveToNext()); if (notSendingObjects.size() > 0) { if (DBG) Log.d(TAG, "Marking " + notSendingObjects.size() + " objects sent"); mHelper.markObjectsAsSent(notSendingObjects); notSendingObjects.clear(); } } catch (Exception e) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { Log.wtf(TAG, "error running notify loop", e); } else { Log.e(TAG, "error running notify loop", e); } } finally { objs.close(); } } mHelper.close(); }