android.app.Application Java Examples

The following examples show how to use android.app.Application. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PicassoModule.java    From firebase-android-sdk with Apache License 2.0 8 votes vote down vote up
@Provides
@FirebaseAppScope
Picasso providesFiamController(
    Application application, PicassoErrorListener picassoErrorListener) {
  okhttp3.OkHttpClient client =
      new OkHttpClient.Builder()
          .addInterceptor(
              new Interceptor() {
                @Override
                public Response intercept(Chain chain) throws IOException {
                  return chain.proceed(
                      chain.request().newBuilder().addHeader("Accept", "image/*").build());
                }
              })
          .build();

  Picasso.Builder builder = new Picasso.Builder(application);
  builder.listener(picassoErrorListener).downloader(new OkHttp3Downloader(client));
  return builder.build();
}
 
Example #2
Source File: AppliverySdk.java    From applivery-android-sdk with Apache License 2.0 6 votes vote down vote up
private static void initializeAppliveryConstants(Application app, String appToken,
    boolean isStoreRelease) {

  //region validate some requirements
  Context applicationContext = Validate.notNull(app, "Application").getApplicationContext();
  Validate.notNull(applicationContext, "applicationContext");
  Validate.hasInternetPermissions(applicationContext, false);
  //endregion

  AppliverySdk.appToken = appToken;
  AppliveryDataManager.INSTANCE.setAppToken(appToken);
  AppliverySdk.isStoreRelease = isStoreRelease;

  AppliverySdk.fileProviderAuthority = composeFileProviderAuthority(app);

  AppliverySdk.applicationContext = applicationContext;

  AppliverySdk.appliveryApiService = AppliveryApiServiceBuilder.getAppliveryApiInstance();
  AppliverySdk.activityLifecycle = new AppliveryActivityLifecycleCallbacks(applicationContext);
  AppliverySdk.permissionRequestManager =
      new AndroidPermissionCheckerImpl(AppliverySdk.activityLifecycle);
}
 
Example #3
Source File: GAletteInstrumentationTest.java    From GAlette with Apache License 2.0 6 votes vote down vote up
@Test
public void weaveSendAppView() throws Exception {
    // Process classes.
    processClass("com.uphyca.galette.GAletteInstrumentationTest$TestClassForSendAppView");

    // Load instrumented classes.
    TestClassForSendAppView instrumentedObject = new TestClassForSendAppView();
    Application app = new Application();
    instrumentedObject.attach(app);

    // Invoke method.
    instrumentedObject.show();

    // Verify interactions.
    Method method = instrumentedObject.getClass().getDeclaredMethod("show", new Class[]{});
    verify(galette).sendAppView(eq(instrumentedObject), eq(app), eq(method), eq(new Object[]{}));
}
 
Example #4
Source File: QTalkSearchRNViewInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static boolean buildBundle(Application application){
    boolean is_ok = false;

    try {
        ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
                .setApplication(application)
                .setJSMainModulePath("index")
                .addPackage(new MainReactPackage())
                .addPackage(new SearchReactPackage())
                .addPackage( new SvgPackage())
                .addPackage(new RNI18nPackage())
                .setUseDeveloperSupport(CommonConfig.isDebug)
                .setInitialLifecycleState(LifecycleState.RESUMED);

        String localBundleFile = getLocalBundleFilePath(application);

        File file = new File(localBundleFile);
        if (file.exists()) {
            // load from cache
            builder.setJSBundleFile(localBundleFile);
        } else {
            // load from asset
            builder.setBundleAssetName(JS_BUNDLE_NAME);
        }

        mReactInstanceManager = builder.build();

        is_ok = true;
    }catch (Exception e){

    }

    return is_ok;
}
 
Example #5
Source File: MyViewModel.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
public MyViewModel(@NonNull Application application) {
    super(application);
    Observable.interval(1, 1, TimeUnit.SECONDS)
        .as(RxLife.asOnMain(this))
        .subscribe(aLong -> {
            Log.e("LJX", "MyViewModel aLong=" + aLong);
        });
}
 
Example #6
Source File: AppModule.java    From Building-Professional-Android-Applications with MIT License 4 votes vote down vote up
@Provides
@Singleton
SharedPreferences providesSharedPreferences(Application application) {
    return PreferenceManager.getDefaultSharedPreferences(application);
}
 
Example #7
Source File: ApplicationTest.java    From AboutIt with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #8
Source File: ApplicationTest.java    From DaggerWorkshopGDG with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #9
Source File: ApplicationTest.java    From example with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
  super(Application.class);
}
 
Example #10
Source File: ApplicationTest.java    From AlexaAndroid with GNU General Public License v2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #11
Source File: ApplicationTest.java    From fab-transformation with MIT License 4 votes vote down vote up
public ApplicationTest() {
  super(Application.class);
}
 
Example #12
Source File: ApplicationTest.java    From SwipeRefreshLayout with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #13
Source File: BackgroundManager.java    From AppCrash with Apache License 2.0 4 votes vote down vote up
public static BackgroundManager init(Application application) {
    if (sInstance == null) {
        sInstance = new BackgroundManager(application);
    }
    return sInstance;
}
 
Example #14
Source File: ApplicationTest.java    From EditTextView with MIT License 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #15
Source File: ApplicationTest.java    From Mortar-Flow-Dagger2-demo with MIT License 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #16
Source File: BundleLifecycleHandler.java    From AtlasForAndroid with MIT License 4 votes vote down vote up
private void started(Bundle bundle) {
    BundleImpl bundleImpl = (BundleImpl) bundle;
    long currentTimeMillis = System.currentTimeMillis();
    String str = (String) bundleImpl.getHeaders().get("Bundle-Application");
    if (StringUtils.isNotEmpty(str)) {
        String[] strArr;
        String[] split = StringUtils.split(str, SymbolExpUtil.SYMBOL_COMMA);
        if (split == null || split.length == 0) {
            strArr = new String[]{str};
        } else {
            strArr = split;
        }
        if (strArr != null) {
            for (String str2 : strArr) {
                String trim = StringUtils.trim(str2);
                if (StringUtils.isNotEmpty(trim)) {
                    try {
                        Application newApplication;
                        int i;
                        for (Application newApplication2 : DelegateComponent.apkApplications.values()) {
                            if (newApplication2.getClass().getName().equals(trim)) {
                                i = 1;
                                break;
                            }
                        }
                        i = 0;
                        if (i == 0) {
                            newApplication2 = newApplication(trim, bundleImpl.getClassLoader());
                            newApplication2.onCreate();
                            DelegateComponent.apkApplications.put("system:" + trim, newApplication2);
                        }
                    } catch (Throwable th) {
                        log.error("Error to start application", th);
                    }
                }
            }
        }
    } else {
        PackageLite packageLite = DelegateComponent.getPackage(bundleImpl.getLocation());
        if (packageLite != null) {
            str2 = packageLite.applicationClassName;
            if (StringUtils.isNotEmpty(str2)) {
                try {
                    newApplication(str2, bundleImpl.getClassLoader()).onCreate();
                } catch (Throwable th2) {
                    log.error("Error to start application >>>", th2);
                }
            }
        }
    }
    log.info("started() spend " + (System.currentTimeMillis() - currentTimeMillis) + " milliseconds");
}
 
Example #17
Source File: ApplicationTest.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #18
Source File: MockRunner.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Application newApplication(ClassLoader cl, String className, Context context)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    return super.newApplication(cl, AppTest.class.getName(), context);
}
 
Example #19
Source File: ApplicationTest.java    From ScreenshotsNanny with MIT License 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #20
Source File: ApplicationTest.java    From Weather2016 with MIT License 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #21
Source File: ApplicationTest.java    From Blorm with MIT License 4 votes vote down vote up
public ApplicationTest() {
  super(Application.class);
}
 
Example #22
Source File: ApplicationModule.java    From AndroidBlueprints with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
SharedPreferences providesSharedPreferences(Application application) {
    return PreferenceManager.getDefaultSharedPreferences(application);
}
 
Example #23
Source File: JobsModule.java    From Building-Professional-Android-Applications with MIT License 4 votes vote down vote up
@Provides
@Singleton
JobManager provideJobManager(Application application, AppJobCreator jobCreator) {
    JobManager.create(application).addJobCreator(jobCreator);
    return JobManager.instance();
}
 
Example #24
Source File: ApplicationTest.java    From AndroidBleManager with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #25
Source File: ApplicationTest.java    From CanPhotos with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #26
Source File: ApplicationTest.java    From JianDan with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
	super(Application.class);
}
 
Example #27
Source File: ApplicationTest.java    From Dexer with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #28
Source File: TelecineModule.java    From Telecine with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton static ContentResolver provideContentResolver(Application app) {
  return app.getContentResolver();
}
 
Example #29
Source File: ApplicationTest.java    From MortgageCalculator with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}
 
Example #30
Source File: ApplicationTest.java    From Emotion-Analysis-API with Apache License 2.0 4 votes vote down vote up
public ApplicationTest() {
    super(Application.class);
}