Tạo 1 Serive
Vào file AndroidManifest.xml thêm dòng vào giữa thẻ <application và </application>
Vào Activity SplashScreenActivity (Activity được gọi đầu tiên của ứng dụng) thêm dòng
public class OnClearFromRecentService extends Service { public OnClearFromRecentService() { } @Override public IBinder onBind(Intent intent) { // TODO: Return the communication channel to the service. throw new UnsupportedOperationException("Not yet implemented"); } @Override public void onTaskRemoved(Intent rootIntent) { super.onTaskRemoved(rootIntent);
// TODO: Code cần làm khi sự kiên TaskRemoved xảy ra
} }
Vào file AndroidManifest.xml thêm dòng vào giữa thẻ <application và </application>
<service android:name=".AppService.OnClearFromRecentService" android:stopWithTask="false" ></service>
Vào Activity SplashScreenActivity (Activity được gọi đầu tiên của ứng dụng) thêm dòng
startService(new Intent(getBaseContext(), OnClearFromRecentService.class));
Nhận xét
Đăng nhận xét