Android Q, programmatically connect to different WiFi AP for internet

Try calling bindProcessToNetwork() in onAvailable() callback to regain network connectivity, it works fine for me. Connect to network: WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder(); builder.setSsid(“wifi-ap-ssid”); builder.setWpa2Passphrase(“wifi-ap-password”); WifiNetworkSpecifier wifiNetworkSpecifier = builder.build(); NetworkRequest.Builder networkRequestBuilder1 = new NetworkRequest.Builder(); networkRequestBuilder1.addTransportType(NetworkCapabilities.TRANSPORT_WIFI); networkRequestBuilder1.setNetworkSpecifier(wifiNetworkSpecifier); NetworkRequest nr = networkRequestBuilder1.build(); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() { @Override public void onAvailable(Network … Read more

Is there an API to detect which theme the OS is using – dark or light (or other)?

Google has just published the documentation on the dark theme at the end of I/O 2019, here. In order to manage the dark theme, you must first use the latest version of the Material Components library: “com.google.android.material:material:1.1.0-alpha06”. Change the application theme according to the system theme For the application to switch to the dark theme … Read more

Can’t start activity from BroadcastReceiver on android 10

Android 10’s restriction on background activity starts was announced about six months ago. You can read more about it in the documentation. Use a high-priority notification, with an associated full-screen Intent, instead. See the documentation. This sample app demonstrates this, by using WorkManager to trigger a background event needing to alert the user. There, I … Read more

API 29 Mediastore Access

I think this is an Android 10 bug, so I’ve filed a report here: https://issuetracker.google.com/issues/147619577 (includes instructions for an emulator test case to reproduce it if that interests you). Please consider starring it to let the Android team know that it affects you. From what I can tell, it only affects files on ‘external’ storage, … Read more

Crash on Android 10 (InflateException in layout/abc_screen_simple line #17)

Update Calligraphy to newest version to solve this problem: Link: https://github.com/InflationX/Calligraphy/issues/35 More specifically, both Calligraphy and ViewPump need to be updated: implementation ‘io.github.inflationx:calligraphy3:3.1.1’ implementation ‘io.github.inflationx:viewpump:2.0.3’ Migrating from Calligraphy 2 to 3 requires some code changes; see examples in Calligraphy 3 README.

“Unknown bits set in runtime_flags: 0x8000” warning in Logcat on Android Q emulator

I bring a stone to the building. I retrace the code for the error message. It is at line 345 in the C ++ file dalvik_system_ZygoteHooks.cc At a minimum, if (runtime_flags! = 0) then the error message will be printed. 0x8000 also corresponds to the USE_APP_IMAGE_STARTUP_CACHE flag (see line 157). The test on the USE_APP_IMAGE_STARTUP_CACHE … Read more

Turning on wifi using WifiManager stops to work on Android 10

public boolean setWifiEnabled (boolean enabled) This method was deprecated in API level 29. Starting with Build.VERSION_CODES#Q, applications are not allowed to enable/disable Wi-Fi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always return false and will have no effect. If apps are targeting an older SDK ( Build.VERSION_CODES.P or below), they can … Read more