List of usage examples for java.net MalformedURLException printStackTrace
public void printStackTrace()
From source file:com.facebook.android.Example.java
/** Called when the activity is first created. */ @Override//from w w w. ja va2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see Example.java"); } setContentView(R.layout.main); mLoginButton = (LoginButton) findViewById(R.id.login); mText = (TextView) Example.this.findViewById(R.id.txt); mRequestButton = (Button) findViewById(R.id.requestButton); mPostButton = (Button) findViewById(R.id.postButton); mDeleteButton = (Button) findViewById(R.id.deletePostButton); mUploadButton = (Button) findViewById(R.id.uploadButton); mFacebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(mFacebook); SessionStore.restore(mFacebook, this); SessionEvents.addAuthListener(new SampleAuthListener()); SessionEvents.addLogoutListener(new SampleLogoutListener()); mLoginButton.init(this, mFacebook); mRequestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mAsyncRunner.request("me", new SampleRequestListener()); } }); mRequestButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); mUploadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Bundle params = new Bundle(); params.putString("method", "photos.upload"); URL uploadFileUrl = null; try { uploadFileUrl = new URL("http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); } catch (MalformedURLException e) { e.printStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection) uploadFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); int length = conn.getContentLength(); byte[] imgData = new byte[length]; InputStream is = conn.getInputStream(); is.read(imgData); params.putByteArray("picture", imgData); } catch (IOException e) { e.printStackTrace(); } mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null); } }); mUploadButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); mPostButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mFacebook.dialog(Example.this, "feed", new SampleDialogListener()); } }); mPostButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); }
From source file:com.jittr.android.facebook.Example.java
/** Called when the activity is first created. */ @Override/*w ww.j a v a 2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see Example.java"); } // mFacebook. setContentView(R.layout.mainfacebook); mLoginButton = (LoginButton) findViewById(R.id.login); mText = (TextView) Example.this.findViewById(R.id.txt); mRequestButton = (Button) findViewById(R.id.requestButton); mPostButton = (Button) findViewById(R.id.postButton); mDeleteButton = (Button) findViewById(R.id.deletePostButton); mUploadButton = (Button) findViewById(R.id.uploadButton); mFacebook = new Facebook(); mAsyncRunner = new AsyncFacebookRunner(mFacebook); SessionStore.restore(mFacebook, this); SessionEvents.addAuthListener(new SampleAuthListener()); SessionEvents.addLogoutListener(new SampleLogoutListener()); mLoginButton.init(mFacebook, PERMISSIONS); mRequestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mAsyncRunner.request("me", new SampleRequestListener()); } }); mRequestButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); mUploadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Bundle params = new Bundle(); params.putString("method", "photos.upload"); URL uploadFileUrl = null; try { uploadFileUrl = new URL("http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); } catch (MalformedURLException e) { e.printStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection) uploadFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); int length = conn.getContentLength(); byte[] imgData = new byte[length]; InputStream is = conn.getInputStream(); is.read(imgData); params.putByteArray("picture", imgData); } catch (IOException e) { e.printStackTrace(); } mAsyncRunner.request(null, params, "POST", new SampleUploadListener()); } }); mUploadButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); mPostButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mFacebook.dialog(Example.this, "stream.publish", new SampleDialogListener()); } }); mPostButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); }
From source file:edu.stanford.mobisocial.dungbeetle.facebook.FacebookInterfaceActivity.java
/** Called when the activity is first created. */ @Override/*from w ww.ja v a 2s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see FacebookInterfaceActivity.java"); } setContentView(R.layout.facebook); mLoginButton = (LoginButton) findViewById(R.id.login); mText = (TextView) FacebookInterfaceActivity.this.findViewById(R.id.txt); mRequestButton = (Button) findViewById(R.id.requestButton); mPostButton = (Button) findViewById(R.id.postButton); mDeleteButton = (Button) findViewById(R.id.deletePostButton); mUploadButton = (Button) findViewById(R.id.uploadButton); mFacebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(mFacebook); SessionStore.restore(mFacebook, this); SessionEvents.addAuthListener(new SampleAuthListener()); SessionEvents.addLogoutListener(new SampleLogoutListener()); mLoginButton.init(this, mFacebook); mRequestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mAsyncRunner.request("me", new SampleRequestListener()); } }); mRequestButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); mUploadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Bundle params = new Bundle(); params.putString("method", "photos.upload"); URL uploadFileUrl = null; try { uploadFileUrl = new URL("http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); } catch (MalformedURLException e) { e.printStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection) uploadFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); int length = conn.getContentLength(); byte[] imgData = new byte[length]; InputStream is = conn.getInputStream(); is.read(imgData); params.putByteArray("picture", imgData); } catch (IOException e) { e.printStackTrace(); } mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null); } }); mUploadButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); mPostButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mFacebook.dialog(FacebookInterfaceActivity.this, "feed", new SampleDialogListener()); } }); mPostButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE); }
From source file:es.tekniker.framework.ktek.questionnaire.mng.server.OrionContextBrokerClient.java
private HttpURLConnection getOrionContextBrokerGEConnection(String method, String service, String contentType) { HttpURLConnection conn = null; URL url = null;//from w w w . jav a2s. co m String urlStr = this.protocol + "://" + service + method; log.debug(urlStr); try { url = new URL(urlStr); conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod(this.methodPOST); conn.setRequestProperty(this.headerContentType, contentType); conn.setConnectTimeout(this.timeout); log.debug(this.headerContentType + " " + contentType); } catch (MalformedURLException e) { log.error("MalformedURLException " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { log.error("IOException " + e.getMessage()); e.printStackTrace(); } return conn; }
From source file:com.he5ed.lib.cloudprovider.auth.OAuth2Fragment.java
/** * Get API access token by sending POST request with params build from AuthHelper * * @param body parameter to be passed with the request */// ww w . ja v a 2s. c om private void getAccessToken(RequestBody body) { String url; try { url = AuthHelper.getAccessTokenUri(mCloudApi).toString(); } catch (MalformedURLException e) { e.printStackTrace(); // register event to listener if (mListener != null) mListener.onAuthError(getString(R.string.auth_error_malformed_url)); return; } Request request = new Request.Builder().url(url).post(body).build(); mHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Request request, IOException e) { // register event to listener if (mListener != null) mListener.onAuthError(getString(R.string.auth_error_access_token_fail)); } @Override public void onResponse(Response response) throws IOException { if (response.isSuccessful()) { try { JSONObject jsonObject = new JSONObject(response.body().string()); mTokenInfo = AuthHelper.extractAccessToken(mCloudApi, jsonObject); if (mTokenInfo != null) { getUserInfo(mTokenInfo.get(Authenticator.KEY_ACCESS_TOKEN)); } else { // register event to listener if (mListener != null) mListener.onAuthError(getString(R.string.auth_error_access_token_fail)); } } catch (JSONException e) { e.printStackTrace(); // register event to listener if (mListener != null) mListener.onAuthError(getString(R.string.auth_error_access_token_fail)); } } else { // register event to listener if (mListener != null) mListener.onAuthError(getString(R.string.auth_error_access_token_fail)); } } }); }
From source file:com.google.gdocsfs.GoogleDocsFS.java
public int mknod(String path, int mode, int rdev) { try {/* w w w. j a va 2s .c om*/ docs.newDocument(path); return 0; } catch (MalformedURLException e) { e.printStackTrace(); return Errno.EIO; } catch (IOException e) { e.printStackTrace(); return Errno.EIO; } catch (ServiceException e) { e.printStackTrace(); return Errno.ENETDOWN; } catch (Exception e) { e.printStackTrace(); return Errno.EIO; } }
From source file:com.keithhutton.ws.proxy.ProxyServlet.java
private void relayXmlRcpRequest(ServletRequest req, ServletResponse resp) { Object theResult = null;//from w ww .j ava2s .co m XmlRpcServerConfigImpl serverConfig = new XmlRpcServerConfigImpl(); serverConfig.setEnabledForExtensions(true); xmlRpcServer.setConfig(serverConfig); XmlRpcHttpRequestConfigImpl streamConfig = new XmlRpcHttpRequestConfigImpl(); streamConfig.setEnabledForExceptions(true); streamConfig.setGzipRequesting(false); ProxyXmlRpcClient theClient = new ProxyXmlRpcClient(); XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); List<Object> params = new ArrayList<Object>(); try { XmlRpcRequest xmlRpcRequest = getMethodAndParamsFromRequest(req); XmlRpcHttpRequestConfig xmlRpcRequestConfig = (XmlRpcHttpRequestConfig) xmlRpcRequest.getConfig(); this.username = xmlRpcRequestConfig.getBasicUserName(); this.password = xmlRpcRequestConfig.getBasicPassword(); this.log.info("Relay to : " + destinationURL + " for user=" + this.username + " with password=" + this.password); URL url = new URL(destinationURL); config.setServerURL(url); config.setBasicUserName(username); config.setBasicPassword(password); config.setEnabledForExtensions(true); theClient.setConfig(config); // Call a method String method = xmlRpcRequest.getMethodName(); int parameterCount = xmlRpcRequest.getParameterCount(); for (int i = 0; i < parameterCount; i++) { params.add(xmlRpcRequest.getParameter(i)); } theResult = theClient.callMethod(method, params); } catch (MalformedURLException mfue) { mfue.printStackTrace(); } catch (XmlRpcException xmlrpce) { xmlrpce.printStackTrace(); } identifyAndLog(theResult); // Now put the result in the response... resp = writeResultToResponseAsXml(streamConfig, resp, theResult); }
From source file:ali.arshad.soomro.openweathermap.androidsdk.WeatherUtil.java
public Bitmap getIconBitmap(WeatherInfo uri) { StringBuilder imgUri = new StringBuilder(ICO_URI); imgUri.append(uri.getWeather().get(0).getIcon()); Bitmap imgIcon = null;// w ww.j a va 2 s .c o m InputStream in; try { in = new java.net.URL(imgUri.toString()).openStream(); imgIcon = BitmapFactory.decodeStream(in); return imgIcon; } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
From source file:org.commonjava.indy.koji.ftest.AbstractKojiIT.java
protected synchronized String formatSSLUrl(String... path) { String baseUrl = getSSLBaseUrl(); try {/*from w ww . j a v a 2 s .c o m*/ return UrlUtils.buildUrl(baseUrl, path); } catch (MalformedURLException e) { e.printStackTrace(); fail(String.format("Failed to format URL from parts: [%s]. Reason: %s", StringUtils.join(path, ", "), e.getMessage())); } return null; }