use of android.app.Application in project platform_frameworks_base by android.
the class RemoteViews method getApplicationInfo.
private static ApplicationInfo getApplicationInfo(String packageName, int userId) {
if (packageName == null) {
return null;
}
// Get the application for the passed in package and user.
Application application = ActivityThread.currentApplication();
if (application == null) {
throw new IllegalStateException("Cannot create remote views out of an aplication.");
}
ApplicationInfo applicationInfo = application.getApplicationInfo();
if (UserHandle.getUserId(applicationInfo.uid) != userId || !applicationInfo.packageName.equals(packageName)) {
try {
Context context = application.getBaseContext().createPackageContextAsUser(packageName, 0, new UserHandle(userId));
applicationInfo = context.getApplicationInfo();
} catch (NameNotFoundException nnfe) {
throw new IllegalArgumentException("No such package " + packageName);
}
}
return applicationInfo;
}
use of android.app.Application in project flow by square.
the class Installer method install.
@NonNull
public Context install() {
if (InternalLifecycleIntegration.find(activity) != null) {
throw new IllegalStateException("Flow is already installed in this Activity.");
}
Dispatcher dispatcher = this.dispatcher;
if (dispatcher == null) {
dispatcher = //
KeyDispatcher.configure(activity, new DefaultKeyChanger(activity)).build();
}
final Object defState = defaultKey == null ? "Hello, World!" : defaultKey;
final History defaultHistory = History.single(defState);
final Application app = (Application) baseContext.getApplicationContext();
final KeyManager keyManager = new KeyManager(contextFactories);
InternalLifecycleIntegration.install(app, activity, parceler, defaultHistory, dispatcher, keyManager);
return new InternalContextWrapper(baseContext, activity);
}
use of android.app.Application in project robospice by stephanenicolas.
the class JsonObjectPersisterFactoryTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Thread.sleep(SMALL_THREAD_SLEEP);
Application application = (Application) getContext().getApplicationContext();
JsonObjectPersisterFactory factory = getJsonObjectPersisterFactory(application);
inFileObjectPersister = factory.createInFileObjectPersister(WeatherResult.class, null);
}
use of android.app.Application in project robospice by stephanenicolas.
the class InDatabaseWeatherPersisterTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Application application = (Application) getInstrumentation().getTargetContext().getApplicationContext();
List<Class<?>> classCollection = new ArrayList<Class<?>>();
// add persisted classes to class collection
classCollection.add(Weather.class);
classCollection.add(CurrenWeather.class);
classCollection.add(Day.class);
classCollection.add(Forecast.class);
classCollection.add(Night.class);
classCollection.add(Wind.class);
RoboSpiceDatabaseHelper databaseHelper = new RoboSpiceDatabaseHelper(application, "sample_database.db", 1);
databaseHelper.clearTableFromDataBase(Weather.class);
InDatabaseObjectPersisterFactory inDatabaseObjectPersisterFactory = new InDatabaseObjectPersisterFactory(application, databaseHelper, classCollection);
dataPersistenceManager = inDatabaseObjectPersisterFactory.createObjectPersister(Weather.class);
TEST_TEMP.setTemp("28");
TEST_TEMP.setTemp_unit("C");
TEST_TEMP2.setTemp("30");
TEST_TEMP2.setTemp_unit("C");
}
use of android.app.Application in project robospice by stephanenicolas.
the class JsonObjectPersisterFactoryTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Thread.sleep(SMALL_THREAD_SLEEP);
Application application = (Application) getContext().getApplicationContext();
RetrofitObjectPersisterFactory factory = getRetrofitObjectPersisterFactory(application);
inFileObjectPersister = factory.createObjectPersister(WeatherResult.class);
}
Aggregations