Skip to content

Commit 1588280

Browse files
committed
Add App Startup.
1 parent 7249459 commit 1588280

6 files changed

Lines changed: 61 additions & 16 deletions

File tree

activitytasklib/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdkVersion 31
55

66
defaultConfig {
77
minSdkVersion 15
8-
targetSdkVersion 28
8+
targetSdkVersion 31
99

1010
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1111
consumerProguardFiles "consumer-rules.pro"
@@ -26,6 +26,7 @@ android {
2626
dependencies {
2727
implementation 'androidx.appcompat:appcompat:1.1.0'
2828
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
29+
implementation 'androidx.startup:startup-runtime:1.1.1'
2930
testImplementation 'junit:junit:4.12'
3031
androidTestImplementation 'androidx.test:runner:1.2.0'
3132
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="cc.rome753.activitytasklib">
4-
5+
<application>
6+
<provider
7+
android:name="androidx.startup.InitializationProvider"
8+
android:authorities="${applicationId}.androidx-startup"
9+
android:exported="false"
10+
tools:node="merge">
11+
<meta-data
12+
android:name="cc.rome753.activitytasklib.ActivityTaskInitializer"
13+
android:value="androidx.startup" />
14+
</provider>
15+
</application>
516
</manifest>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cc.rome753.activitytasklib;
2+
3+
import android.app.Application;
4+
import android.content.Context;
5+
6+
import androidx.annotation.NonNull;
7+
import androidx.startup.Initializer;
8+
9+
import java.util.Collections;
10+
import java.util.List;
11+
12+
public class ActivityTaskInitializer implements Initializer<Void> {
13+
14+
@NonNull
15+
@Override
16+
public Void create(@NonNull Context context) {
17+
ActivityTaskHelper.init((Application) context);
18+
return null;
19+
}
20+
21+
@NonNull
22+
@Override
23+
public List<Class<? extends Initializer<?>>> dependencies() {
24+
return Collections.emptyList();
25+
}
26+
}

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdkVersion 31
55
defaultConfig {
66
applicationId "cc.rome753.activitytask.demo"
77
minSdkVersion 15
8-
targetSdkVersion 28
8+
targetSdkVersion 31
99
versionCode 1
1010
versionName "1.0"
1111
}
@@ -21,7 +21,7 @@ android {
2121
}
2222

2323
dependencies {
24-
implementation project(path: ':activitytasklib')
24+
debugImplementation project(path: ':activitytasklib')
2525
implementation 'androidx.appcompat:appcompat:1.1.0'
2626
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
2727
testImplementation 'junit:junit:4.12'

app/src/main/AndroidManifest.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:label="@string/app_name"
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
12+
<activity android:name=".MainActivity"
13+
android:exported="true">
1314
<intent-filter>
1415
<action android:name="android.intent.action.MAIN" />
1516

@@ -18,17 +19,23 @@
1819
</activity>
1920
<activity
2021
android:name=".DialogActivity"
21-
android:theme="@style/dialogstyle" />
22-
<activity android:name=".StandardActivity" />
22+
android:theme="@style/dialogstyle"
23+
android:exported="false" />
24+
<activity android:name=".StandardActivity"
25+
android:exported="false" />
2326
<activity android:name=".SingleTopActivity"
24-
android:launchMode="singleTop" />
27+
android:launchMode="singleTop"
28+
android:exported="false" />
2529
<activity
2630
android:name=".SingleTaskActivity"
27-
android:launchMode="singleTask" />
31+
android:launchMode="singleTask"
32+
android:exported="false" />
2833
<activity
2934
android:name=".SingleInstanceActivity"
30-
android:launchMode="singleInstance" />
31-
<activity android:name=".DemoFragmentActivity" />
35+
android:launchMode="singleInstance"
36+
android:exported="false" />
37+
<activity android:name=".DemoFragmentActivity"
38+
android:exported="false" />
3239
</application>
3340

3441
</manifest>

app/src/main/java/cc/rome753/demo/DemoApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class DemoApplication extends Application{
1616
public void onCreate() {
1717
super.onCreate();
1818

19-
if(BuildConfig.DEBUG) {
20-
ActivityTaskHelper.init(this);
21-
}
19+
// if(BuildConfig.DEBUG) {
20+
// ActivityTaskHelper.init(this);
21+
// }
2222
}
2323

2424
}

0 commit comments

Comments
 (0)