Skip to content

Instantly share code, notes, and snippets.

ext.densityCodes = ['mdpi': 1, 'hdpi': 2, 'xhdpi': 3]
import com.android.build.OutputFile
android {
.....
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
android {
.....
splits {
density {
enable true
reset()
include "mdpi", "xhdpi"
}
abi {
android {
...
splits {
abi {
enable true
reset()
include "x86", "mips"
universalApk false
}
android {
.......
.......
splits {
density {
enable true
exclude "mdpi", "xxxhdpi"
compatibleScreens 'small', 'normal', 'large', 'xlarge'
}
}
public class LocationListenerActivity extends Activity implements LocationUpdate{
@Override
public void onLocationChange(Location location){
}
@Override
public void onStart(){
LocationListener.get().register(this);
public class MainActivity extends AppCompatActivity {
TextView textView;
AsyncTask asyncTask;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.textView);
public class MainActivity extends AppCompatActivity {
private static Button button; //NEVER USE LIKE THIS
private static Context context; //NEVER USE LIKE THIS TOO
}
<activity android:name=".ui.splash.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<application
android:name=".MvpApp"
......
......
......
......
</application>
public class MvpApp extends Application {
DataManager dataManager;
@Override
public void onCreate() {
super.onCreate();
SharedPrefsHelper sharedPrefsHelper = new SharedPrefsHelper(getApplicationContext());
dataManager = new DataManager(sharedPrefsHelper);