Skip to content

Commit 4c13275

Browse files
committed
fix(boot):fix boot for API < 26
Signed-off-by: Teclib <[email protected]>
1 parent b65ed95 commit 4c13275

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/src/main/java/org/glpi/inventory/agent/broadcast/BootStartAgent.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ public void onReceive(Context context, Intent intent) {
6868
SharedPreferences customSharedPreference = PreferenceManager.getDefaultSharedPreferences(context);
6969
if (customSharedPreference.getBoolean("boot", false)) {
7070
try {
71-
Intent myIntent = new Intent(context, InventoryService.class);
71+
7272
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
73+
Intent myIntent = new Intent(context, InventoryService.class);
7374
context.startForegroundService(myIntent);
7475
} else {
75-
context.startService(myIntent);
76+
Intent myIntent = new Intent(context, ActivityMain.class);
77+
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
78+
context.startActivity(myIntent);
7679
}
7780
}catch(Exception ex) {
7881
Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();

app/src/main/java/org/glpi/inventory/agent/service/InventoryService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,10 @@ public void onCreate() {
104104
mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 5, NOTIFY_INTERVAL);
105105
intent = new Intent(TIMER_RECEIVER);
106106

107-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
107+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
108108
startMyOwnForeground();
109-
}else{
110-
startForeground(1, new Notification());
111109
}
112110

113-
114111
}
115112

116113
@RequiresApi(api = Build.VERSION_CODES.O)

0 commit comments

Comments
 (0)