intentservice

Location listener works from a Service but not an IntentService

佐手、 提交于 2020-01-01 00:34:06
问题 I have an app where I am trying to periodically get user location and send to server. I have a service attached to an AlarmManager which executes every minute (for testing). The service finds the user location correctly and logs out the GPS co-ords. Once there is a GPS lock I cancel the location request and stop the service. When I ask for location updates, I start a Handler that executes 20 seconds later, this Handler removes the location update and stops the Service in case no lock is

How to Keep the CPU of android phone always awake?

隐身守侯 提交于 2019-12-31 02:43:10
问题 I have been stuck on it for days. I need to execute a function every minute. This function is making a POST call from the App to the Server and is transferring the location of the user per minute. The location coordinates are transferred for few hours, however, after few hours the transfer of location coordinates to the Server stops on its own. I am making use of WakefulBroadcastReceiver and IntentService to make sure that the CPU stays awake. I am also making use of Alarm to make sure that

Design pattern for alternate action if app in foreground?

你离开我真会死。 提交于 2019-12-29 08:01:35
问题 I'm building an action which utilizes Google Cloud Messaging for receiving push notifications. This involves a couple notable components, namely: A WakefulBroadcastReceiver to receive the message from GCM. An IntentService to be notified when a GCM event is received. As I'm sure is the case for many applications, I'd like to take a different approach for when the application has an activity in the foreground vs. when the application does not have an application in the foreground. I'd like to

Is there any reason to continue using IntentService for handling GCM messages?

瘦欲@ 提交于 2019-12-29 07:44:51
问题 As you know, recently Google changed their GCM documentation, and they claim that an IntentService is no longer required for handling arriving GCM messages. All the handling can be done in the BroadcastReceiver . When trying to figure out if there is any good reason to continue using the IntentService , I came across this quote: A Service (typically an IntentService) to which the WakefulBroadcastReceiver passes off the work of handling the GCM message, while ensuring that the device does not

IntentService源码分析

☆樱花仙子☆ 提交于 2019-12-27 07:20:53
我们带着问题来看源码! 一. IntentService如何单独开启一个新的工作线程? @Override public void onCreate ( ) { // TODO: It would be nice to have an option to hold a partial wakelock // during processing, and to have a static startService(Context, Intent) // method that would launch the service & hand off a wakelock. super . onCreate ( ) ; // 1 HandlerThread thread = new HandlerThread ( "IntentService[" + mName + "]" ) ; thread . start ( ) ; // 2 mServiceLooper = thread . getLooper ( ) ; //3 mServiceHandler = new ServiceHandler ( mServiceLooper ) ; } 1.实例化HandlerThread新建线程并启动,这里注意HandlerThread 继承自Thread,内部封装了Looper; 2.

Fetching user location in background and uploading it to web server (trying to avoid using Service)

空扰寡人 提交于 2019-12-25 00:34:04
问题 My application is based on Google Map and Location which includes client-server communications. Apart from all that, periodically I want to update the user location to web server. I gave thought myself and ended up with below two scenarios, First One : I use Service class to fetch user location periodically (considering 2-3 hours once) and update to server. Ideally I want to avoid this! Because just to upload user location its not good to run the service all the time is what I feel. Second

IntentService Stops After Data Insertion into SQLite and Gives NULLPOINTER EXCEPTION when insert 2nd time

拜拜、爱过 提交于 2019-12-24 18:20:35
问题 I'm developing an app in which data saved into database when there is no covered area of mobile signals. When service came back it will fetch all data from database and upload on server. Now I have two problems. IntentService stops when 1st time data inserted into database.(When network service came back it also upload data on the server, for checking network connectivity I used timer.) I don't want to stop service. When 2nd time I start the service it created again and Gives

Android start service of an app from another android app

谁都会走 提交于 2019-12-24 14:17:05
问题 I have two applications installed on the device: from one app I want to start a service as follows: Intent i = new Intent(); i.setComponent(new ComponentName("com.app.service", "com.app.service.NotificationService")); context.startService(i); The second app is only installed but not started. What I want is to start the notification service(which should create a notification) from the second service by using the above code. In the manifest file of the second app I declare the service as

Stop a service when application is in background

被刻印的时光 ゝ 提交于 2019-12-24 13:15:49
问题 I'm new to android and I am creating a MAC spoofing app. I have created an IntentService to spoof the MAC address in the app every 5 seconds and it is working fine. Then I created a BaseActivity which all of my activities extend from, this is so I can detect when the app goes in the background or not, this is also working fine. I already have it so when the app is in the background, the MAC address no longer changes and goes back to its original, but instead of this I want to just stop the

Intent to Hidden Application on Android

早过忘川 提交于 2019-12-24 03:33:05
问题 I have two application. I want to intent to the second one from the first one. But the second application must be launched from first one. So i have to hide the second one's icon. When i delete the category tag from the second one's manifest.xml, icon is disappearing. But this time i can't launch the second app from the first app with intent. This is how i tried to intent: Intent openvideo = getPackageManager().getLaunchIntentForPackage("air.deneme"); startActivity(openvideo); How can i