FAQ Database Discussion Community


android intent: when can the action be null?

android,android-intent,android-service
In an already existing projects I see that a service checks if the intent is null and if the intent action is null. I know that the intent action will be null if the service is invoked as: context.startService(new Intent(context, MyService.class)); but I do not know whether or not the...

Broadcast receiver in a service doesn't receive alarm signal

android,android-intent,android-service,android-broadcast,android-alarms
Here is my problem, I have a service started on boot or on the launch of the application, this service start an alarm which download a file every x minutes. The problem is that the broadcast receiver doesn't seems to receive anything. here is the concerned code: @Override public int...

intent in static method is null when passed to pending intent

android,android-service,android-pendingintent
I'm currently nearly done an app I'm working on, except for a new roadblock. My app includes a service alarm that fires as intended, the intents within it work at the exact times they're set, and everything else is working fine. However, my app has menu button that lets you...

Sync Adapter not calling onCreate

android,android-intent,android-activity,android-service,android-syncadapter
Do we need to start the Sync Adapter service or framework starts implicitly? I have put a log on Constructor, onCreate, onDestroy of Sync Adapter service and when I start the app, I don't see the logs in the logcat. But when I do on activity onCreate Intent serviceIntent =...

how to start service and stop it at another activity in android

android,android-service,tracking
my Service never stop until I uninstall the app #HELP! service class public class LocationService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { GPSTracker myGps = new GPSTracker(getApplicationContext()); Log.e("tracking...",""); return START_STICKY; } @Override public IBinder onBind(Intent intent) { return null; } @Override public boolean...

Error in android service class

android,android-service
I am getting the following error in service class. What is the issue here ? Error:(17, 8) error: NotificationService is not abstract and does not override abstract method onBind(Intent) in Service This is my code : package works.viswajith.birthdayreminder; import android.app.NotificationManager; import android.app.Service; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.database.DatabaseUtils;...

How to send data from IntentService to Non-Activity class

android,android-service,android-broadcast,intentservice
I have two Service class. one is WebsocketService(extends Service) to manage Websocket related function and SocketMessageProcessing(extends IntentService) to process response Received in WebSocketService. From Non-Activity(SocketImpl) class I am successfully able to send data to WebsocketService. But I am having trouble in sending response back to SocketImpl class from SocketMessageProcessing class....

Android AlarmManager Pass extra from activity to service

android-service,android-notifications,android-pendingintent,android-alarms
I have tried to follow many links but no matter what my extras keep being null. First I have an activity (MainActivity) that will set up a notification using a service (NotifyService). I can get the service to be and the notification to appear at the appropriate time. However passing...

Android - Difference between Broadcast Receiver and Service

android,android-intent,broadcastreceiver,android-service,android-broadcast
I am wondering, what would be the difference between registering broadcast receiver statically in the manifest and starting a service? Both will run even if the app is in the background and it seems to me that receiver is much less complicated to code. Am I missing something here?

Is Android's Wakelock a necessity for background services?

android,android-service,wakelock,android-wake-lock
I am writing a long-running background service that collects and analyzes device data. To do this I start a service, the service spawns a thread and the thread does the data collection / analysis. From my reading I have learned that if I want the service to do it's thing...

Android is killing my service?

android,service,broadcastreceiver,android-service,android-background
with a BroadCastReceiver, I execute a service at the smartphone boot: public class BootReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { Intent startServiceIntent = new Intent(context, MyService.class); context.startService(startServiceIntent); } } MyService: private Runnable myRunnable = new Runnable() { public void run() { parsing.cancel(true); parsing = new Parsing();...

AlarmManager - Am I doing it right?

android,broadcastreceiver,android-service,alarmmanager,android-broadcast
I had setup AlarmManager in my MainActivity class. A class called AlarmReceiver gets fired up for every set interval of time. I have to perform an operation when that class is fired up. That code is in in another class Parsing.java Now in AlarmReceiver.java, I'm doing this : public class...

Android notifications get service that started the notification?

android,android-intent,service,notifications,android-service
I have a service that performs an operation after a certain delay. I want to show a notification when the service is started, and when the notification is clicked it cancels the operation. No UI, all done in the background. The service is started on boot by a broadcast receiver....

My service seems to restart when I close my app

android,android-service
I have a service which creates a CountDownTimer and then displays a Notification and updates it according to CountDownTimer. The problem comes when I close the app. Even if CountDownTimer is already half done, it will reset when app is completely closed. This is the main part of Service cass:...

Android Service Notification onclick

java,android,android-activity,android-service
I have a foreground service, and I'd like to make the Notification open the MainActivity when the user clicks on the Notification. The method for creating the Notification in the custom Service class is: public void setForeground(final int notificationID, final int notificationIconID, final String notificationTickerText, final String notificationTitle, final String...

android - service for interaction with wearable

android,android-service,android-wear,google-api-client,android-wear-data-api
I tried creating a service (which extends WearableListenerService) which should send as well as receive data with wearable. But when i created GoogleApiClient object in that service, it failed with NullPointerException. public class MyService extends WearableListenerService{ private GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .build(); private final String MESSAGE_PATH = "/message";...

Will intentService result in concurrecny issue with the activity

android,android-service,android-intentservice
I have read that IntentService create worker thread for the work to be done. If I understand correctly, then that means that the work will be done on a thread other than the UI thread. My question is if my activity is trying to update shared preferences and this intentService...

Receiving intent if the activity/app is destroyed

android,android-intent,broadcastreceiver,android-service,android-download-manager
I am developing an app where I need to download a large mp3 from an URL and when it has completed update a database with the path where it has been stored, so that in case there is no internet connection the user can play it. I have thought in...

Android - Tamagotchi game background service

android,android-intent,unity3d,android-service
I try to build a Tamagotchi game with Unity for Android. The Tamagotchi has a food attribute that should go down even when the Game is closed. So my approach would be build a IntentService that holds the variables, increase and decrease them if needed. For Batterie reasons i would...

Android: how to communicate from worker thread to a service

java,android,multithreading,android-service
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...

Application crash with no exception after resuming

android,android-service,android-mediaplayer,surfaceview
I am making simple app to display video and plaing audio playback if activity is in background. My app works fine if i just turn screen off/on. It crashes when I resume my app after brawsing another application. Log cat show no error. import android.app.Activity; import android.content.Intent; import android.media.MediaPlayer; import...

Return http request result to an activity

android,android-asynctask,android-service
I have to develop an Android application that perform a http GET request to a server that responds with a JSON string. Because I need to do that request more times in the app I've created a class only to do this task using AsyncTask. The problem is that I'm...

Android - Is there a way to register my Activity and Service other than Manifest file [closed]

android,android-intent,android-activity,android-service,android-manifest
Actually I want to know the other way if exist to register my Activity and Service similar to LocalBroadcast Reciever.

How to start and keep sockets connections accross multiple activities?

android,sockets,android-service
i'm having trouble finding a way to implement this: I have an activity A from where i'll start 2x separate socket connections. Afterwards i'll move to an activity B from where i'll go back and fourth with activities C and D. All 3 activities will exchange messages via the sockets....

Using Trust Agents in android app

android,android-service,android-5.0-lollipop,trust
I'm trying to use recently added TrustAgents. Manifest made by comments in official Android sources on Git. As there is said after implementing such manifest I will be able to extend classes from TrustAgentService. That's it: <uses-permission android:name="android.permission.CONTROL_KEYGUARD" /> <uses-permission android:name="android.permission.PROVIDE_TRUST_AGENT" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <service...

Unable to create service

android,service,android-service
I'm new to android and creating a service in one of my reminder application. but I my service is triggering when i call the startService() in my onCreate() method of my activity I am unable to see the toasts which are used in different methods of my service class.As new...

How to replace findViewById() with LayoutInflater.inflate() for a watch view stub

android,android-layout,android-service,android-wear
I have a watch app but am investigating replacing the activity with a system overlay window. The standard way of inflating a wearable's layout is to use: WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); However, if I am no longer using the activity instead I will be creating the system overlay window...

how to handle start service in landscape or portrait mode in android…?

android,android-activity,android-service
In My application i Have create one services for downloading data,so my requirement is when i run my application then the service call only one time. but practically is it not possible, when screen rotate from landscape mode to portrait mode then activity get Restart and services again call to...

Activtiy and service both reference the same object

android,android-service
If I have an activity that starts a background service so that the service remains when the activity is destroyed. And I need both the Service and the activity to be a referencing the same object ( because this object is expensive to construct and lives with the app as...

Separate thread background service with communication with activity in Android application

android,multithreading,broadcastreceiver,android-service,android-broadcast
I'm an experienced Web-developer, but I'm very new to the Android SDK and Java. I have a conceptual question regarding background operations and multithreading in Android application. I'm going to develop an app which will has a constantly-working background service (it will communicate with remote server over HTTP). Also, I'm...

Getting GPS in service in android

android,gps,android-service,android-handler
My problem is not new, but none of answers in Stackoverflow was helpful for me. Situation: I have a service which works with an Alarm. it repeats every 1 minutes and run a service for me. in that service I need to send GPS data to a web server. the...

WatchFaces are not configuring

java,android,android-service,android-wear,watch-face-api
I have created watchface for android wear and my code is as follows: ComapnionConfigActivity (in mobile module): import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.wearable.Wearable; public class CompanionConfigActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks,...

ActivityNotFoundException while trying to start a service.

android,android-service
I am getting an Activity not found exception while trying to start a service. I have the service registered in the Manifest. Adding what I think is the relevant code and the LogCat. Let me know if you need to see any more. 01-29 17:41:51.440 9196-9196/drvr.drvlog E/AndroidRuntime﹕ FATAL EXCEPTION: main...

How to pause the service when the home button is pressed and resume the service when the program is resume?

android,android-service
public class BackgroundMusicService extends Service { int currentPos; /** indicates how to behave if the service is killed */ int mStartMode; /** interface for clients that bind */ IBinder mBinder; /** indicates whether onRebind should be used */ boolean mAllowRebind; MediaPlayer player; @Override public void onCreate() { super.onCreate(); player =...

Can I update the UI of an activity which is in background?

android,android-activity,android-asynctask,android-service
The question is more conceptual than coding-related. I have an app with Activity A and B. I call an AsyncTask from Activity A, while the call is being made, I don't want to block the user showing the progressdialog, so my user can freely move around the application without getting...

IntentService - find number of Intents waiting in the queue

android,android-service,android-intentservice
In my app I use an IntentService to do some work. I want to find out how many intents are waiting to be processed, as IntentService holds them in a 'work queue' , and sends the next one to onStartCommand() as the onStartCommand of the previous one has finished. How...

One service or multiple services

android,android-service
I have an application which will have Sticky Service. This service does GPS location queries all the time. However, I want to have tasks done when I alarm is expired/Bluetooth is connected. These are short lived tasks and I wanted to have services for them . My question is: Should...

General Query About How To Detect What Intent Called The Service

android,android-intent,android-service,android-pendingintent
So I have a app with different settings for up to 8 things and I have been trying to pass on which PendingIntent or Intent triggered my service but all to no avail. I have tried using the .getExtra() and .putExtra() and also trying to figure out what the int...

Android - My service onunbind but no bind again

android,android-activity,android-service,android-service-binding
I'm stuck in a problem with a service binding that is giving me nuts. I got an activity that is binding a service, and is frequent that the user go in and out of that activity. The problem comes when the user goes out first time of the activity this...

How to know when the services has ended

android,android-service,android-broadcast
I want know when the service has ended, so I use BroadcastReceiver. My service name is CheckNuevosAvisosIntentServices and I launch it in main.java (onCreate method) as: Intent msgIntent = new Intent(Main.this, CheckNuevosAvisosIntentService.class); msgIntent.putExtra("iteraciones", 1); startService(msgIntent); My manifest inside application tag. <!-- Services --> <service android:name="com.kirolm.instalacionesdep.services.CheckNuevosAvisosIntentService" /> In another fragment (HomeFragment)...

Androidmanifest build error about receiver within a service

android,android-intent,android-studio,android-service,android-broadcast
I'm trying to build an application with gradle>assembleRelease on AndroidStudio but I have an error: Error:(31) Error: The element must be a direct child of the element [WrongManifestParent] the concerned code is : <service android:enabled="true" android:name="com.example.xx.ServiceCalendar"> <receiver android:name="com.example.xx.ServiceCalendar"> <intent-filter> <action android:name="ALARM_DL" /> <action android:name="ALARM_PARSE" /> <action android:name="ALARM_NOTIF" /> </intent-filter>...

dynamically changing text in android floating view

android,android-layout,android-intent,android-activity,android-service
i am just a beginner in android and i am assigned to create a floating view for our android team project, i have been able to create the service so far and now i am trying to somehow change the image in the floating view to a dynamically changing text...

Service Intent must be explicit

android,android-intent,android-service,android-mediaplayer
I'm trying to use service for a background music. package com.example.neotavraham; import android.app.Service; import android.content.Intent; import android.media.MediaPlayer; import android.os.IBinder; import android.util.Log; public class PlayMusicService extends Service implements MediaPlayer.OnPreparedListener { public static final String ACTION_PLAY = "com.example.neotavraham.PLAY"; MediaPlayer mMediaPlayer = null; @Override public int onStartCommand(Intent intent, int flags, int startId) {...

Audio manager nullpointerexception in service

android,service,nullpointerexception,android-service,android-audiomanager
I need help with that, i found one more same question but didnt work for me. Thats my code: import android.app.Service; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.media.AudioManager; import android.net.Uri; import android.os.Handler; import android.os.IBinder; import android.provider.CallLog; import android.provider.ContactsContract; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; import...

Canceling Android Alarms / Notifications

android,android-service,android-notifications,android-pendingintent,android-alarms
I have an app that notifies you if you have any bills to pay. I want one notification for each bill due. The alarm is set to go off at an exact time in the day. I have everything working except for one aspect: The alarm goes away after I...

My service is not stop what is a reason. how to fixed it

android,android-service
I start service from an activity startservice(intent); when i call for stopping service stopservice(intent); but service it does not stop. actually my service class contains LocationListener that get latitude and longitude and then store in sqlite and also sent such information into server. another issue is LocationUpdate method is automatically...

android service, context, builder

java,android,android-service,builder,android-context
I read around in Android Developer, but I didn't understand completely those 3 "ideas": 1) context 2) builder 3) service and how do they relate to each other? I saw for example: GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(context) and I didn't get exactly what the general purpose of each "idea"....

Capture camera frames in background (Android)

android,opengl-es,android-camera,android-service
My problem is this: I want a background service, that will obtain frames from the camera in real-time, so that I can analyze them. I've seen a lot of similar topics here that supposedly address this issue, but none of them has really worked in my case. My first attempt...

what is meant by making android service private?

android,android-service
I was reading my homework slides and part of them mentioned that a service could be made private with the following code: android:exported = false i mean to say about theoretical explanation for making a service public / private , not on the coding point of view !!...

Do BroadcastReceiver, Service, and Activity share Application object?

android,android-activity,android-service,android-broadcast,android-context
I have among others the following components: a BroadcastReceiver registered in Manifest a STICKY Service normally started by boot complete which processes Intents from the above BroadcastReceiver an Activity which binds to the Service (starting it if for some reason does not exist) Under which circumstances do these components share...

Pass data from activity to service ? Android

android,android-service
How many I can pass data to Service by Intent . I am passing 7 data to Service but the latter two is null . This code is in MainActivity.class : Intent Class = new Intent(MainActivity.this, Class_Service.class); Class.putExtra("Url", URL); Class.putExtra("Username", Username); Class.putExtra("PASSWORD", PASSWORD); Class.putExtra("Mobile", Mobile); Class.putExtra("HQStudentID", HQStudentID); Class.putExtra("_SchoolCode", SchoolCode); Class.putExtra("_GroupID",...

How to correctly manage a Thread's lifecycle from a Service?

android,android-service
I've noticed something while I was reading the Service API Guide (more specifically this section). In the following code snippet, a new HandlerThread is created and started every time the Service is created: @Override public void onCreate() { // Start up the thread running the service. Note that we create...

How to use alertDialog in background service

android,android-service,android-alertdialog
I need to prompt a alertDialog in a background service, but it crashed by the bad context, how can I handle it, where I can get the right Context?

Broadcast reciever not working from service

android,broadcastreceiver,android-service
I am trying to use BroadcastReceiver inside my service but it is not working properly. I am starting my service in an onCreate in my activity. Then in the services onCreate I am calling the following to register the Broadcast reciever: IntentFilter filter = new IntentFilter(); registerReceiver(DataUpdateReceiver, filter); Here's the...

Android Service not running in background?

android,android-service
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...

Manually switch notificationListenerService on and off

java,android,android-intent,service,android-service
How would you go about switching a notificationListenerService on and off manually using buttons? At the moment the service starts the moment the app is allowed in Security->Notifications however I'm unsure how to prevent this and do it manually instead. I realise there are functions such as startService() but am...

Android Service stops automatically without calling stopService()

android,android-service,android-music-player
I have made an android Service to play music, when i close my application then it keeps on playing song for few minutes and then automatically stops without even calling destroy method. I am not able to understand why is it happening. Below is the code of my Service class....

AlarmManager With BroadcastReceiver Not Firing

broadcastreceiver,android-service,alarmmanager
I have an AlarmManager that is set in a BroadcastReceiver subclass using a Service subclass as the context. The AlarmManager is not firing. I know that the AlarmManager is being set with the correct milliseconds. Any ideas for why the AlarmManager is not firing? public class Alarm extends BroadcastReceiver {...

Android Wear Watch Face get battery percentage of Phone

java,android,android-service,android-wear
I'm developing an Android Wear Watch Face and I want to show the battery percentage of the watch and the phone. I managed to get the percentage of the Watch but I'm new to Java & Android so please go easy on me with the explaining. private String getBatteryInfoPhone() {...

What happens to a Service object after it's destroyed

android,android-service,android-service-binding
Let's say I binded to a service, and got an object reference to it through the IBinder object. I store the reference in my Activity object as a field. Then I unbind the service causing its destruction. What does the Service reference in the Activity refers to after the Service's...

Declaring an external service in the manifest

android,android-service,android-manifest,linphone
This is a follow up question to this question: Calling a service from an External JAR in Android I am using Eclipse and I got a service which is defined in an external jar. The jar is in the Android Private Libraries in the project's folder. The answer to the...

Alarm receive don't work

android,android-intent,android-service,android-pendingintent,android-broadcast
I'm making an alarm receiver, but the alarm is not triggered. This is my code : Start alarm in MainActivity : private void setupAlarm(){ Intent intent = new Intent(this, com.logdata.AlarmReceiver.class); PendingIntent pIntent = PendingIntent.getService(this, 0, intent, 0); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + 1, 1000, pIntent); Log.e("setupAlarm", "Setup alarm...

Display notification daily with AlarmManager and Service

android,android-service,android-notifications
I want to daily display a notification, however the notification is displayed every other now and then. So far I haven't figured out the pattern. In my MainActivity#onCreate I execute this code for starting it: final Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.add(Calendar.DAY_OF_YEAR, 1); final AlarmManager...

Retrieve old value of Intent in onStartCommand of Service

android,android-intent,nullpointerexception,android-service
SUMMARY: I have a little problem of logic about how to retrieve (or keep) the Intent information in my onStartCommand method. SCENE: My MainActivity starts a service with a String value ... Intent intent = new Intent(this, Service.class); intent.putExtra("key", getIntent().getStringExtra("key")); startService(intent); ... then mi Service uses this Intent value —...

NavigationBar buttons not responding on a layout drawn from Service

java,android,android-layout,android-service,android-windowmanager
I am trying to implement an AlertWindow kind of thing where I am using the instance of WindowsManager to add a View on it from a Service. The View is visible and accessible. But the back/home buttons on the on-screen NavigationBar don't seem to respond. I am new to Android....

Initiating a task, navigating away from the app and coming back to see it completed

android,android-service
...Again on my journey of learning Android Service... On multiple occasions, I noticed that as a user, you can initiate a task by clicking a button on the app then navigate away from the app. When you come back, you find the task is done. This is done in many...

AsyncTask is not running when called with execute

android,android-asynctask,android-service
I am trying to run an AsynTask that updates a local data every minute. I have placed logging statements in all paths of the AsyncTask, yet none of them are ever called. Am I not creating/running the async task correctly? Here is the receiver calling the function (I know that...

processes & singleton in Android

android,singleton,android-service
Three questions concerning processes in Android. I am developing one app. If I declare a service to be running in another process in AndroidManifest.xml <service android:name=".MyService" android:process=":MyProcess"/> Does it mean there will be two JVM instances , one used by MyService while the other one used by other code? If...

Starting Android IntentService with explicit intent NullPointerException

java,android,android-intent,android-service
I'm trying to start an IntentService from a clickhandler in my main activity. I'm studying Intents right now but don't quite get it yet. I'm not sure how I'm supposed to instantiate my intent here and pass it to startService. I don't know why I have to do such a...

How to download files as soon as user's mobile is connected to internet?

android,parse.com,android-service
I'm working on a project which requires data to be downloaded to user's phone(Android) as and when he is connected to the internet. This should be irrespective of whether the application is in foreground or not. PS: I know how to download files from server and store it in user's...

postDelayed() in a Service

android,android-service,android-handler
I'm trying to restart service from itself in a few time. My code looks like this (inside the onStartCommand(...)) Looper.prepare(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(BackgroundService.this, BackgroundService.class); startService(intent); } }, 3 * 60000); Service is running in the...

Independent time tracking in android app: service or asynctask?

android,android-asynctask,broadcastreceiver,android-service
I'm trying to do a time tracking app: you push "start" on a task, timer launches somewhere, counts its time, after some time limit a notification is shown - "you are late", but timer goes on. App has many activities, timer should update UI on one of them. An it...

Killing an activity that started a sticky service kills the service too

android,android-service
I am using an empty activity to start a sticky service. I start the service using the following code. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent service = new Intent(this, MyService.class); service.setAction("com.company.test.MyService"); startService(service); finish(); setContentView(R.layout.activity_transparent); } The problem is that if the activity gets killed it will cause the...

Handler and Thread inside Service keeps running, while the Service seems to have stopped

java,android,multithreading,android-service,android-handler
I have a Service that uses Handler and Thread to run some code every 5 seconds. When I call stopSelf() the service seems to have stopped, because from the device Setting -> Apps -> Running it doesn't show there. But the code inside the thread keeps on running every 5...

Different implied intents in onHandleIntent between two notifications

java,android,android-intent,android-service
I'm new to working in Android, and I'm not sure if I wrote myself into a corner or if I'm just not seeing the solution (either is likely). I have an intentservice which sets repeating alarms based on those times a user saves. When the alarms go off, the intention...

Android periodically get location and post to server using Service

android,android-service,alarmmanager,locationlistener
I use a service class that implements LocationListener, to get the location at periodic intervals, and post to server at only when there is considerable change in the latlon(min 100 meters). Because, continuously updating server drains battery quickly. I start this service from onCreate() of myActivity, and don't call stopService()...

Starting Service in Android calls Applications onCreate

android,android-intent,android-service
I am starting an android service using, startService(getApplicationContext(), MyService.class); I have correctly defined my service in AndroidManifest. Now, I am calling above code from Application create. Case 1: Calling above code from Application onCreate() I see that Application.onCreate() gets called two time. One is the desired App create and other...

Android - Ensuring that Wakelock is released when a Service's process is killed by OS

android,android-service,android-lifecycle,android-wake-lock
I want my FusedLocationProvider to ping for location even when the screen is off. For this, in my service, I have a PARTIAL_WAKE_LOCK, to keep the CPU running and to ensure that the service continues to run even when the screen is off. That being said, I know the Android...

Unable to start Android Service

android,android-intent,android-activity,android-service
I am trying to make a build a simple service kinda facebook chathead but for some reason i am not able to start the service, whenever i click on the start service button nothing happens. if someone can help me here and tell me what am i doing wrong, i...

Passing extras from Activity to Intent throws NullPointerException

java,android,android-intent,android-service
This is a problem that forked off a different issue. I'm passing two strings from my main activity to a child service, which is fine, but when the main activity dies, the service throws a NullPointerException trying to grab the two strings. From MainActivity: Intent i = new Intent(this, PebbleService.class);...

Getting java.lang.ClassCastException: android.os.BinderProxy every time i declare and run two services

java,android,android-service,android-service-binding
I am encountering following binder.proxy exception every time i declare and run two services. One service runs in different Process(Private to app) and another service runs in same process as My Application is running in(Default App Process) with a Binder Implementation. AndroidManifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.service.check" android:versionCode="1" android:versionName="1.0"...

Android Timer which works on both background and foreground

android,timer,android-service,wakelock,background-service
I'm now working on an app which will track students' studying time. The student can press start button and start studying. And stop when he finish studying. When screen is on or phone is plugged in,the text view and progress bar is updating every second .(I means it works fine)...

Does startService always create a new Service or is the Intent sent to the existing one?

android,android-intent,android-service
I am developing an Android application where I start a Service via an Intent. The service opens a connection and reports its success to an Activity. Afterwars the user shall be able to start a data transmission via Button click. This is also done by the service. Is it the...

getting location updates with background service

android,android-service,android-location,android-alarms,android-googleapiclient
i have just started to learn how to use services, and i am trying to build an app which sets off an alarm when the device is in a certain distance from a location that the user defined. i read a couple of tutorial and wrote this: package com.example.fgps; import...

Managed Query is not defined for service?

android,android-service
I am trying to get call logs with this code but I am getting error that managedQuery is not defined for service: private void getCallDetails() { StringBuffer sb = new StringBuffer(); Cursor managedCursor = managedQuery( CallLog.Calls.CONTENT_URI,null, null,null, null); int number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER ); int type = managedCursor.getColumnIndex( CallLog.Calls.TYPE );...

Android - passing data from Service to main at unknown point in time

android,android-intent,android-service
I've looked at some of the other questions here on SO and none seem to be answering my question. I have a main activity with a simple button. Right now it calls startService(new Intent(MainActivity.this, BluetoothScanner.class) which runs until it finds another bluetooth device. When this is done, I want the...

Permissions are not recognized

android,permissions,android-service
I have a problem with permissions in android. I want to track if my device sent or received a sms. For this, I use a service that runs in background. Permissions in mainfest.xml: <uses-permssion android:name="android.permission.READ_SMS"/> <uses-permission android:name="android.permission.RECEIVE_SMS"/> <uses-permssion android:name="android.permission.WRITE_SMS"/> Here is the errorlog: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.telephony.MmsSmsProvider from...

Scheduled Alarm Manager not working Android

android,broadcastreceiver,android-service,alarmmanager,repeatingalarm
I am trying to start an alarm service that repeats every day at a particular time. I have gone through a lot of threads on stack overflow regarding this but no luck. I followed a few tutorials: http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/ and http://javatechig.com/android/repeat-alarm-example-in-android My service is never started and I do not understand...