use of android.app.Application in project freeline by alibaba.
the class FreelineApplication method createRealApplication.
private void createRealApplication() {
String applicationClass = getConfigValue("applicationClass");
if (TextUtils.isEmpty(applicationClass)) {
realApplication = new Application();
Log.d(TAG, "create empty application.");
} else {
try {
Class realClass = Class.forName(applicationClass);
Constructor<? extends Application> constructor = realClass.getConstructor();
this.realApplication = constructor.newInstance();
Log.d(TAG, "create application: " + applicationClass);
} catch (Exception e) {
FreelineCore.printStackTrace(e);
Log.e(TAG, "create real application error");
}
}
}
use of android.app.Application in project platform_frameworks_base by android.
the class FalsingLog method wtf.
public static synchronized void wtf(String tag, String s) {
if (!ENABLED) {
return;
}
e(tag, s);
Application application = ActivityThread.currentApplication();
String fileMessage = "";
if (Build.IS_DEBUGGABLE && application != null) {
File f = new File(application.getDataDir(), "falsing-" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".txt");
PrintWriter pw = null;
try {
pw = new PrintWriter(f);
dump(pw);
pw.close();
fileMessage = "Log written to " + f.getAbsolutePath();
} catch (IOException e) {
Log.e(TAG, "Unable to write falsing log", e);
} finally {
if (pw != null) {
pw.close();
}
}
} else {
Log.e(TAG, "Unable to write log, build must be debuggable.");
}
Log.wtf(TAG, tag + " " + s + "; " + fileMessage);
}
use of android.app.Application in project platform_frameworks_base by android.
the class DpiTestActivity method init.
public void init(boolean noCompat) {
try {
// This is all a dirty hack. Don't think a real application should
// be doing it.
Application app = ActivityThread.currentActivityThread().getApplication();
ApplicationInfo ai = app.getPackageManager().getApplicationInfo("com.google.android.test.dpi", 0);
if (noCompat) {
ai.flags |= ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS | ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS | ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
app.getResources().setCompatibilityInfo(new CompatibilityInfo(ai, getResources().getConfiguration().screenLayout, getResources().getConfiguration().smallestScreenWidthDp, false));
}
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("ouch", e);
}
}
use of android.app.Application in project platform_packages_apps_launcher by android.
the class Launcher method registerIntentReceivers.
/**
* Registers various intent receivers. The current implementation registers
* only a wallpaper intent receiver to let other applications change the
* wallpaper.
*/
private void registerIntentReceivers() {
if (sWallpaperReceiver == null) {
final Application application = getApplication();
sWallpaperReceiver = new WallpaperIntentReceiver(application, this);
IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
application.registerReceiver(sWallpaperReceiver, filter);
} else {
sWallpaperReceiver.setLauncher(this);
}
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
registerReceiver(mApplicationsReceiver, filter);
}
use of android.app.Application in project freeline by alibaba.
the class GradleDynamic method applyDynamicRes.
@Override
public boolean applyDynamicRes(HashMap<String, String> dynamicRes) {
String dynamicResPath = dynamicRes.get(FreelineCore.DEFAULT_PACKAGE_ID);
Log.i(TAG, "dynamicResPath: " + dynamicResPath);
if (!TextUtils.isEmpty(dynamicResPath)) {
Application realApplication = FreelineCore.getRealApplication();
MonkeyPatcher.monkeyPatchApplication(app, app, realApplication, dynamicResPath);
MonkeyPatcher.monkeyPatchExistingResources(app, dynamicResPath, Arrays.asList(ActivityManager.getAllActivities()));
Log.i(TAG, "GradleDynamic apply dynamic resource successfully");
}
return true;
}
Aggregations