App Startup

Jetpack新成员,App Startup一篇就懂

使用示例

  1. 导包
dependencies {
    api "androidx.startup:startup-runtime:1.0.0"
}
  1. 创建初始化的类实现Initializer接口
public class PhotoEditorInitializer implements Initializer {

    @NonNull
    @Override
    public Void create(@NonNull Context context) {
        ActivityLifecycle.get().initialize((Application) context);
        PhotoEditor.init(context);
        DataManager.get().registerContentObserver(context);
        return null;
    }

    @NonNull
    @Override
    public List>> dependencies() {
        List>> initializerList = new ArrayList<>();
//        initializerList.add(ProjectInitializer.class);
        return initializerList;
    }
}
  1. AndroidManifest.xml配置就可以了
        
        
            
            
                
                
            
            

            
        

你可能感兴趣的:(App Startup)