android-service

Android:Music Player,Unable to start service with null point exception?

百般思念 提交于 2019-12-08 14:04:57
问题 There were no errors until i added broadcast receiver for showing the progress of the seekbar.The app was working fine before. Code for the activity. package source.justanothermusicplayer; import java.io.Serializable; import java.util.ArrayList; import source.justanothermusicplayer.classes.SongDetails; import source.justanothermusicplayer.service.Music_service; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent;

Stop the background service after particular time in android

瘦欲@ 提交于 2019-12-08 14:01:26
Hi i need to stop the Background service which is already started after particular time.I will get the duration from server for when to stop the service.I have tried the Alarm Manager in android. Calendar cal = Calendar.getInstance(); Intent intent = new Intent(context, MyService.class); PendingIntent pintent = PendingIntent.getService(context, 0, intent, 0); AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); // Start every 30 seconds alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 60*1000, pintent); Log.e(TAG, "Service started in Activity");

App not letting device to go into sleep mode

。_饼干妹妹 提交于 2019-12-08 13:05:39
问题 I'm developing an application in which I'm using an activity which will come on top of default lock screen of the device. All things are perfectly fine, but I'm having issues with display timeout of the screen . Every time when my activity comes, the device does not go into sleep mode. Why? Here is my code snippet for Service class and BroadcastReceiver class. I could find out what is hindering the device screen timeout mode. BroadcastReceiver class @Override public void onReceive(Context

Android: how to communicate from worker thread to a service

一世执手 提交于 2019-12-08 12:26:52
问题 I've created a service class and a worker class that is executed in a separate thread. I would like to setup a communication between them, so the worker could send some status back to the service. I've tried to convert my worker Thread to HandlerThread and setup a Handler on the service side, but then I don't know how to actually send a message from the worker. It looks like I can't grasp the concept. Here's my classes (without communication logic): Service class package com.example.app;

Android O - Background service limitation not working as expected

假如想象 提交于 2019-12-08 12:04:26
问题 I was just testing my existing android application against Android O background limitations. In testing, I found a strange behavior. So basically in my application, I am using background service and I am starting it in very first activity. So now the issue is once the activity and background service gets started, I am closing my activity using the back button. So as per the service concepts, it keeps running in the background. After approx 1 min onDestroy() method gets called of background

Android BroadcastReceiver Not being called after app closed from Running App List

一笑奈何 提交于 2019-12-08 11:15:14
问题 In attempting to implement notifications in an android app, I am seeing that the notifications no longer work if a user closes the app from the Running App List (top swipe down and then horizontal swipe - not force quit which properly would shut down all future invocations as per google specs). Using the back button sometimes causes the same behaviour, though not always. My understanding from everything that I have researched is that only a force stop by the user should stop the Broadcast

Doze mode - do foreground services continue to run?

我是研究僧i 提交于 2019-12-08 11:09:30
问题 im so confused reading this and trying to figure out if foreground services will run when the device goes into deep doze mode. Could someone clarify. I want to know on marshmallow and upwards if foreground services can continue to run. I always thought ALL THREADs are suspended even foreground services when device sleeps. I see the doze mode restrictions but nothing about foreground services. im so confused if my services outlives doze mode security settings. From what i can tell in the doze

Android O service stops

泄露秘密 提交于 2019-12-08 11:05:58
问题 my background service stops on android 8.1.0 MainClass: private void startTracking() { if (!isMyServiceRunning()) { Intent intent = new Intent(MainActivity.this, BackgroundDetectedActivitiesService.class); startService(intent); } } private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (BackgroundDetectedActivitiesService

Android Service not running in background?

江枫思渺然 提交于 2019-12-08 10:40:28
问题 The service runs when I press home button or back button but the service is not running in background when app is closed. Moreover the service runs in background in some(LG Nexus 5) phones, but in most of the phones(Samsung,Xioami) service is not running when app is closed. When i goto Settings > Apps > Running, It always shows as app running and displays 1 service 1 thread. I am calling the service from MainActivity.java I want the service always running in background even if the app is

How to launch an Android App when it is not running

被刻印的时光 ゝ 提交于 2019-12-08 10:28:31
问题 I am interested in figuring out how to launch an Android App when it is not running. Lets assume the app is already installed on the user's device, but the app is not running. When the user accesses a particular wifi network, I'd like the app to be launched automatically. How can this be accomplished? Would you recommend to use an Android Service that is running in the background to launch the app? Does the Android Service run in the background at all times? Would this put a heavy load on the