Commit c9a2393f authored by fallenstardust's avatar fallenstardust

让安卓O以上允许后台服务

parent 3062c6d4
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
......@@ -112,7 +113,12 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//autoupadte checking
checkPgyerUpdateSilent(getContext());
//ServiceDuelAssistant
startService(new Intent(this, ServiceDuelAssistant.class));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
this.startForegroundService(new Intent(this, ServiceDuelAssistant.class));
} else {
startService(new Intent(this, ServiceDuelAssistant.class));
}
//萌卡
StartMycard();
}
......
package cn.garymb.ygomobile.ui.plus;
import android.app.Notification;
import android.app.Service;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.view.Gravity;
......@@ -73,6 +75,9 @@ public class ServiceDuelAssistant extends Service {
public void onCreate() {
// TODO: Implement this method
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(1,new Notification());
}
//lc = new ArrayList<Card>();
//cladp = new CardListRecyclerViewAdapter(this, lc);
......
......@@ -22,7 +22,6 @@ public class IOUtils {
private static final String TAG = "ioUtils";
public static void close(Closeable closeable) {
Log.i("关了没","closeable的值"+ closeable);
if (closeable != null) {
try {
closeable.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment