List of usage examples for android.net Proxy PROXY_CHANGE_ACTION
String PROXY_CHANGE_ACTION
To view the source code for android.net Proxy PROXY_CHANGE_ACTION.
Click Source Link
From source file:Main.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static boolean setProxyLollipop(final Context context, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {//from w w w. j a v a 2 s . co m Context appContext = context.getApplicationContext(); Class applictionClass = Class.forName("android.app.Application"); Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk"); mLoadedApkField.setAccessible(true); Object mloadedApk = mLoadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers"); mReceiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class clazz = receiver.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); onReceiveMethod.invoke(receiver, appContext, intent); } } } } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:Main.java
@SuppressLint("NewApi") @SuppressWarnings("all") private static boolean setProxyKK(WebView webView, String host, int port, String applicationClassName) { Context appContext = webView.getContext().getApplicationContext(); if (null == host) { System.clearProperty("http.proxyHost"); System.clearProperty("http.proxyPort"); System.clearProperty("https.proxyHost"); System.clearProperty("https.proxyPort"); } else {// www.jav a2 s . c om System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); } try { Class applictionCls = Class.forName(applicationClassName); Field loadedApkField = applictionCls.getField("mLoadedApk"); loadedApkField.setAccessible(true); Object loadedApk = loadedApkField.get(appContext); Class loadedApkCls = Class.forName("android.app.LoadedApk"); Field receiversField = loadedApkCls.getDeclaredField("mReceivers"); receiversField.setAccessible(true); Map receivers = (Map) receiversField.get(loadedApk); for (Object receiverMap : receivers.values()) { for (Object rec : ((Map) receiverMap).keySet()) { Class clazz = rec.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); /*********** optional, may be need in future *************/ final String CLASS_NAME = "android.net.ProxyProperties"; Class cls = Class.forName(CLASS_NAME); Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class); constructor.setAccessible(true); Object proxyProperties = constructor.newInstance(host, port, null); intent.putExtra("proxy", (Parcelable) proxyProperties); /*********** optional, may be need in future *************/ onReceiveMethod.invoke(rec, appContext, intent); } } } Log.d(LOG_TAG, "Setting proxy with >= 4.4 API successful!"); return true; } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } return false; }
From source file:ca.psiphon.tunneledwebview.WebViewProxySettings.java
@TargetApi(Build.VERSION_CODES.KITKAT) @SuppressWarnings("rawtypes") private static boolean setWebkitProxyKitKat(Context appContext, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {//from w w w . j ava 2 s . c om Class applicationClass = Class.forName("android.app.Application"); Field loadedApkField = applicationClass.getDeclaredField("mLoadedApk"); loadedApkField.setAccessible(true); Object loadedApk = loadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field receiversField = loadedApkClass.getDeclaredField("mReceivers"); receiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class receiverClass = receiver.getClass(); if (receiverClass.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = receiverClass.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); final String CLASS_NAME = "android.net.ProxyProperties"; Class proxyPropertiesClass = Class.forName(CLASS_NAME); Constructor constructor = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class); constructor.setAccessible(true); Object proxyProperties = constructor.newInstance(host, port, null); intent.putExtra("proxy", (Parcelable) proxyProperties); onReceiveMethod.invoke(receiver, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } catch (IllegalArgumentException e) { } catch (NoSuchMethodException e) { } catch (InvocationTargetException e) { } catch (InstantiationException e) { } return false; }
From source file:com.psiphon3.psiphonlibrary.WebViewProxySettings.java
@TargetApi(Build.VERSION_CODES.KITKAT) @SuppressWarnings("rawtypes") private static boolean setWebkitProxyKitKat(Context appContext, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {// w ww .ja v a 2s . c o m Class applicationClass = Class.forName("android.app.Application"); Field loadedApkField = applicationClass.getDeclaredField("mLoadedApk"); loadedApkField.setAccessible(true); Object loadedApk = loadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field receiversField = loadedApkClass.getDeclaredField("mReceivers"); receiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class receiverClass = receiver.getClass(); if (receiverClass.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = receiverClass.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); final String CLASS_NAME = "android.net.ProxyProperties"; Class proxyPropertiesClass = Class.forName(CLASS_NAME); Constructor constructor = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class); constructor.setAccessible(true); Object proxyProperties = constructor.newInstance(host, port, null); intent.putExtra("proxy", (Parcelable) proxyProperties); onReceiveMethod.invoke(receiver, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (NoSuchFieldException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (IllegalAccessException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (IllegalArgumentException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (NoSuchMethodException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (InvocationTargetException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (InstantiationException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } return false; }
From source file:ca.psiphon.tunneledwebview.WebViewProxySettings.java
@TargetApi(Build.VERSION_CODES.KITKAT) // for android.util.ArrayMap methods @SuppressWarnings("rawtypes") private static boolean setWebkitProxyLollipop(Context appContext, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {//from ww w . j a v a2 s . c o m Class applictionClass = Class.forName("android.app.Application"); Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk"); mLoadedApkField.setAccessible(true); Object mloadedApk = mLoadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers"); mReceiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class clazz = receiver.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); onReceiveMethod.invoke(receiver, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } catch (NoSuchMethodException e) { } catch (InvocationTargetException e) { } return false; }
From source file:org.mycard.net.network.RequestQueue.java
/*** * Enables data state and proxy tracking *///w w w . j a va 2 s . com public synchronized void enablePlatformNotifications() { //if (HttpLog.LOGV) HttpLog.v("RequestQueue.enablePlatformNotifications() network"); if (mProxyChangeReceiver == null) { mProxyChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { setProxyConfig(); } }; mContext.registerReceiver(mProxyChangeReceiver, new IntentFilter(Proxy.PROXY_CHANGE_ACTION)); } // we need to resample the current proxy setup setProxyConfig(); }
From source file:org.adblockplus.android.ProxyService.java
@SuppressLint("NewApi") @Override// w w w . j av a2 s . c om public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { // Proxy is running in separate thread, it's just some resolution request during initialization. // Not worth spawning a separate thread for this. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build(); StrictMode.setThreadPolicy(policy); } // Get port for local proxy SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Resources resources = getResources(); // Try to read user proxy settings String proxyHost = null; String proxyPort = null; String proxyExcl = null; String proxyUser = null; String proxyPass = null; if (NATIVE_PROXY_SUPPORTED) { // Read system settings proxyHost = System.getProperty("http.proxyHost"); proxyPort = System.getProperty("http.proxyPort"); proxyExcl = System.getProperty("http.nonProxyHosts"); Log.d(TAG, "PRX: " + proxyHost + ":" + proxyPort + "(" + proxyExcl + ")"); // not used but left for future reference String[] px = ProxySettings.getUserProxy(getApplicationContext()); if (px != null) Log.d(TAG, "PRX: " + px[0] + ":" + px[1] + "(" + px[2] + ")"); } else { // Read application settings proxyHost = prefs.getString(getString(R.string.pref_proxyhost), null); proxyPort = prefs.getString(getString(R.string.pref_proxyport), null); proxyUser = prefs.getString(getString(R.string.pref_proxyuser), null); proxyPass = prefs.getString(getString(R.string.pref_proxypass), null); } // Check for root privileges and try to install transparent proxy if (RootTools.isAccessGiven()) { try { initIptables(); StringBuffer cmd = new StringBuffer(); int uid = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.uid; cmd.append(iptables); cmd.append(IPTABLES_RETURN.replace("{{UID}}", String.valueOf(uid))); String rules = cmd.toString(); RootTools.sendShell(rules, DEFAULT_TIMEOUT); transparent = true; } catch (FileNotFoundException e) { // ignore - this is "normal" case } catch (NameNotFoundException e) { Log.e(TAG, "Failed to initialize iptables", e); } catch (IOException e) { Log.e(TAG, "Failed to initialize iptables", e); } catch (RootToolsException e) { Log.e(TAG, "Failed to initialize iptables", e); } catch (TimeoutException e) { Log.e(TAG, "Failed to initialize iptables", e); } } if (!transparent) { // Try to set native proxy nativeProxyAutoConfigured = ProxySettings.setConnectionProxy(getApplicationContext(), LOCALHOST, port, ""); if (NATIVE_PROXY_SUPPORTED) { registerReceiver(connectionReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); registerReceiver(connectionReceiver, new IntentFilter(Proxy.PROXY_CHANGE_ACTION)); } } // Save current native proxy situation. The service is always started on the first run so // we will always have a correct value from the box SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(getString(R.string.pref_proxyautoconfigured), transparent || nativeProxyAutoConfigured); editor.commit(); registerReceiver(proxyReceiver, new IntentFilter(ProxyService.BROADCAST_PROXY_FAILED)); registerReceiver(filterReceiver, new IntentFilter(AdblockPlus.BROADCAST_FILTERING_CHANGE)); registerReceiver(filterReceiver, new IntentFilter(AdblockPlus.BROADCAST_FILTER_MATCHES)); // Start proxy if (proxy == null) { // Select available port and bind to it, use previously selected port by default portVariants[0] = prefs.getInt(getString(R.string.pref_lastport), -1); ServerSocket listen = null; String msg = null; for (int p : portVariants) { if (p < 0) continue; try { listen = new ServerSocket(p, 1024); port = p; break; } catch (IOException e) { Log.e(TAG, null, e); msg = e.getMessage(); } } if (listen == null) { sendBroadcast(new Intent(BROADCAST_PROXY_FAILED).putExtra("msg", msg)); return; } // Save selected port editor.putInt(getString(R.string.pref_lastport), port); editor.commit(); // Initialize proxy proxyConfiguration.put("handler", "main"); proxyConfiguration.put("main.prefix", ""); proxyConfiguration.put("main.class", "sunlabs.brazil.server.ChainHandler"); if (transparent) { proxyConfiguration.put("main.handlers", "urlmodifier adblock"); proxyConfiguration.put("urlmodifier.class", "org.adblockplus.brazil.TransparentProxyHandler"); } else { proxyConfiguration.put("main.handlers", "https adblock"); proxyConfiguration.put("https.class", "org.adblockplus.brazil.SSLConnectionHandler"); } proxyConfiguration.put("adblock.class", "org.adblockplus.brazil.RequestHandler"); if (logRequests) proxyConfiguration.put("adblock.proxylog", "yes"); configureUserProxy(proxyConfiguration, proxyHost, proxyPort, proxyExcl, proxyUser, proxyPass); proxy = new ProxyServer(); proxy.logLevel = Server.LOG_DIAGNOSTIC; proxy.setup(listen, proxyConfiguration.getProperty("handler"), proxyConfiguration); proxy.start(); } if (transparent) { // Redirect traffic via iptables try { StringBuffer cmd = new StringBuffer(); cmd.append(iptables); cmd.append(IPTABLES_ADD_HTTP.replace("{{PORT}}", String.valueOf(port))); String rules = cmd.toString(); RootTools.sendShell(rules, DEFAULT_TIMEOUT); } catch (FileNotFoundException e) { // ignore - this is "normal" case } catch (IOException e) { Log.e(TAG, "Failed to initialize iptables", e); } catch (RootToolsException e) { Log.e(TAG, "Failed to initialize iptables", e); } catch (TimeoutException e) { Log.e(TAG, "Failed to initialize iptables", e); } } prefs.registerOnSharedPreferenceChangeListener(this); // Lock service hideIcon = prefs.getBoolean(getString(R.string.pref_hideicon), resources.getBoolean(R.bool.def_hideicon)); startForeground(ONGOING_NOTIFICATION_ID, getNotification()); // If automatic setting of proxy was blocked, check if user has set it manually boolean manual = isManual(); if (manual && NATIVE_PROXY_SUPPORTED) { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); updateNoTrafficCheck(connectivityManager); } sendStateChangedBroadcast(); Log.i(TAG, "Service started"); }
From source file:org.chromium.ChromeProxy.java
private void onSettingsChanged() { Context appContext = this.cordova.getActivity().getApplicationContext(); // See http://stackoverflow.com/questions/32245972/android-webview-non-fqdn-urls-not-routing-through-proxy-on-lollipop // and https://crbug.com/525945 for the source of this pattern. try {/*w w w . j av a 2s. c o m*/ Class<?> applicationClass = Class.forName("android.app.Application"); Field mLoadedApkField = applicationClass.getDeclaredField("mLoadedApk"); mLoadedApkField.setAccessible(true); Object mloadedApk = mLoadedApkField.get(appContext); Class<?> loadedApkClass = Class.forName("android.app.LoadedApk"); Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers"); mReceiversField.setAccessible(true); ArrayMap<?, ?> receivers = (ArrayMap<?, ?>) mReceiversField.get(mloadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap<?, ?>) receiverMap).keySet()) { Class<?> clazz = receiver.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); onReceiveMethod.invoke(receiver, appContext, intent); } } } } catch (Exception e) { // TODO } }
From source file:com.psiphon3.psiphonlibrary.WebViewProxySettings.java
@TargetApi(Build.VERSION_CODES.KITKAT) // for android.util.ArrayMap methods @SuppressWarnings("rawtypes") private static boolean setWebkitProxyLollipop(Context appContext, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {//from www . j a va2 s.c o m Class applictionClass = Class.forName("android.app.Application"); Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk"); mLoadedApkField.setAccessible(true); Object mloadedApk = mLoadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers"); mReceiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class clazz = receiver.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); onReceiveMethod.invoke(receiver, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (NoSuchFieldException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (IllegalAccessException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (NoSuchMethodException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (InvocationTargetException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } return false; }
From source file:info.guardianproject.netcipher.web.WebkitProxy.java
@TargetApi(19) private static boolean setKitKatProxy(String appClass, Context appContext, String host, int port) { //Context appContext = webView.getContext().getApplicationContext(); if (host != null) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); }/*from w ww . java2s.c om*/ try { Class applictionCls = Class.forName(appClass); Field loadedApkField = applictionCls.getField("mLoadedApk"); loadedApkField.setAccessible(true); Object loadedApk = loadedApkField.get(appContext); Class loadedApkCls = Class.forName("android.app.LoadedApk"); Field receiversField = loadedApkCls.getDeclaredField("mReceivers"); receiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk); for (Object receiverMap : receivers.values()) { for (Object rec : ((ArrayMap) receiverMap).keySet()) { Class clazz = rec.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); if (host != null) { /*********** optional, may be need in future *************/ final String CLASS_NAME = "android.net.ProxyProperties"; Class cls = Class.forName(CLASS_NAME); Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class); constructor.setAccessible(true); Object proxyProperties = constructor.newInstance(host, port, null); intent.putExtra("proxy", (Parcelable) proxyProperties); /*********** optional, may be need in future *************/ } onReceiveMethod.invoke(rec, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } catch (NoSuchFieldException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } catch (IllegalAccessException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } catch (IllegalArgumentException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } catch (NoSuchMethodException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } catch (InvocationTargetException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } catch (InstantiationException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); Log.v(TAG, e.getMessage()); Log.v(TAG, exceptionAsString); } return false; }