Skip to content

Instantly share code, notes, and snippets.

View tosinonikute's full-sized avatar
🏠
Working from home

Tosin Onikute tosinonikute

🏠
Working from home
View GitHub Profile
APK splits allow developers to build multiple APKs for different screen sizes and ABIs. Enabling APK splits ensures that the minimum amount of files required to support a particular device are packaged into an APK.
The following snippet shows an example build.gradle with APK splits enabled.
```
apply plugin: 'com.android.application'
android {
// Specify that we want to split up the APK based on ABI
splits {
long startTime;
long endTime;
long fileSize;
OkHttpClient client = new OkHttpClient();
// bandwidth in kbps
private int POOR_BANDWIDTH = 150;
private int AVERAGE_BANDWIDTH = 550;
private int GOOD_BANDWIDTH = 2000;
NetworkInfo info = Connectivity.getNetworkInfo(context);
if(info.getType() == ConnectivityManager.TYPE_WIFI){
// do something
} else if(info.getType() == ConnectivityManager.TYPE_MOBILE){
// check NetworkInfo subtype
if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_GPRS){
// Bandwidth between 100 kbps and below
} else if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_EDGE){
// Bandwidth between 50-100 kbps
} else if(info.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_0){
private ConnectionQuality mConnectionClass = ConnectionQuality.UNKNOWN;
private ConnectionClassManager mConnectionClassManager;
private DeviceBandwidthSampler mDeviceBandwidthSampler;
private ConnectionChangedListener mListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Listener to update the UI upon connectionclass change.
private class ConnectionChangedListener
implements ConnectionClassManager.ConnectionClassStateChangeListener {
@Override
public void onBandwidthStateChange(ConnectionQuality bandwidthState) {
mConnectionClass = bandwidthState;
runOnUiThread(new Runnable() {
@Override
public void run() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mConnectionClassManager = ConnectionClassManager.getInstance();
mDeviceBandwidthSampler = DeviceBandwidthSampler.getInstance();
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("IMAGE_URL_HERE")
.build();
mDeviceBandwidthSampler.startSampling();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
e.printStackTrace();
compile 'com.facebook.network.connectionclass:connectionclass:1.0.1'
compile 'com.squareup.okhttp3:okhttp:3.3.0'
<?php
$url = "https://fcm.googleapis.com/fcm/send";
$values = array();
$values ['title'] = "This is my message title";
$values ['body'] = "This is my message body";
$data = array();
$data ['to'] = "/topics/news";
$data ['data'] = $values;