P pappicio Active Member Licensed User Longtime User Mar 25, 2013 #1 hi all, is possible to translate this java code into readeable b4a code? B4X: public int setUsbTethering(boolean enable) { final android.net.IConnectivityManager mService; try { return mService.setUsbTethering(enable); } catch (RemoteException e) { return 2; } } } thanks a lot.
hi all, is possible to translate this java code into readeable b4a code? B4X: public int setUsbTethering(boolean enable) { final android.net.IConnectivityManager mService; try { return mService.setUsbTethering(enable); } catch (RemoteException e) { return 2; } } } thanks a lot.
Erel B4X founder Staff member Licensed User Longtime User Mar 26, 2013 #2 This code will not work. mService is null. Where did you see it? Upvote 0
P pappicio Active Member Licensed User Longtime User Mar 26, 2013 #3 Erel said: This code will not work. mService is null. Where did you see it? Click to expand... on internet, on a forum tolking about it... I don't remember where exactly.... (maybe forgot to paste something....) btw thanks. if I'll have more code on it, I'll post. Upvote 0
Erel said: This code will not work. mService is null. Where did you see it? Click to expand... on internet, on a forum tolking about it... I don't remember where exactly.... (maybe forgot to paste something....) btw thanks. if I'll have more code on it, I'll post.
Aleksandr Member Licensed User Longtime User Aug 20, 2014 #4 is possible to translate this java code into readeable b4a code? B4X: mUsbTether = (CheckBoxPreference) findPreference(USB_TETHER_SETTINGS); private void setUsbTethering(boolean enabled) { ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); mUsbTether.setChecked(false); if (cm.setUsbTethering(enabled) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { mUsbTether.setSummary(R.string.usb_tethering_errored_subtext); return; } mUsbTether.setSummary(""); } Source: https://github.com/android/platform.../src/com/android/settings/TetherSettings.java Upvote 0
is possible to translate this java code into readeable b4a code? B4X: mUsbTether = (CheckBoxPreference) findPreference(USB_TETHER_SETTINGS); private void setUsbTethering(boolean enabled) { ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); mUsbTether.setChecked(false); if (cm.setUsbTethering(enabled) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { mUsbTether.setSummary(R.string.usb_tethering_errored_subtext); return; } mUsbTether.setSummary(""); } Source: https://github.com/android/platform.../src/com/android/settings/TetherSettings.java
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2014 #5 Try this (GetContext is available in the JavaObject tutorial thread): B4X: Dim cm As JavaObject = GetContext.RunMethod("getSystemService", Array("connectivity")) Log(cm.RunMethod("setUsbTethering", Array(True)) You also need to add the android.permission.CHANGE_NETWORK_STATE with the manifest editor. The return values: Upvote 0
Try this (GetContext is available in the JavaObject tutorial thread): B4X: Dim cm As JavaObject = GetContext.RunMethod("getSystemService", Array("connectivity")) Log(cm.RunMethod("setUsbTethering", Array(True)) You also need to add the android.permission.CHANGE_NETWORK_STATE with the manifest editor. The return values: