android-service

How to update Activity every time the data had been changed in Service

烂漫一生 提交于 2019-12-24 09:30:04
问题 I'm writing my first Android app and it's supposed to count steps (via accelerometer, source code from http://www.gadgetsaint.com/android/create-pedometer-step-counter-android/) So what do I have for now: MainActivity with three TextView fields (steps, bonuses, speed). Service where I detect steps and calculate distanse, bonus and speed. This service is a Bound Service and it consist of three classes: MyService, MyServiceBinder and MyServiceConnection. I've done it as explained in Xamarin

Timer Vs thread sleep in Services

霸气de小男生 提交于 2019-12-24 09:27:15
问题 I need to check every 15 minutes a feed RSS file in order to update my application's results; I know I have to implement a service, but I was wondering which approach I should use to do this; is it better to implement a timer (http://developerlife.com/tutorials/?p=356) or a thread inside the service (http://www.youtube.com/watch?v=yfWsp9IHX1Y)? I tried the first tutorial but I get the error "Can’t create handler inside thread that has not called Looper prepare in Android"... What should I do?

android service - opening socket throws null exception

你说的曾经没有我的故事 提交于 2019-12-24 08:58:28
问题 I'm trying to create remote service that will take care for all client-server communication for few different apps. The main idea is starting the service from main activity and open a communication socket to a server. after that, the socket will be used by other apps - that's why i want to use remote service for it... now i have an issue with the socket connection, it throws null exception on my device. it works fine on AVD using older android version. here's some parts of my code: my main

Android handheld and wearable not receiving messages

℡╲_俬逩灬. 提交于 2019-12-24 08:56:02
问题 I'm trying to send a message from a wearable to a handheld and then a response from the handheld to the wearable (both modules use the same code and logic). Gradle : compile 'com.google.android.support:wearable:2.0.0-alpha2' compile 'com.google.android.gms:play-services-wearable:9.6.1' ... classpath 'com.android.tools.build:gradle:2.2.1' classpath 'com.google.gms:google-services:3.0.0' AndroidManifest : <application> ... <service android:name=".ReceiverService" android:enabled="true" android

Context error of custom system service

依然范特西╮ 提交于 2019-12-24 08:29:57
问题 I have created a system service that communicates with a zigbee device. Updated APIs and created system.img and flashed on the device and made custom SDK for android programming. In the Mainactivity class, try { ZigbeeManager zm = (ZigbeeManager) getSystemService(Context.ZIGBEE_SERVICE); zm.write("Hello World!\r"); } catch (Exception ex) { Log.d(TAG, "Error in Zigbee Service: " + ex.toString()); } I am getting an error over the words "Context.ZIGBEE_SERVICE". It says "Must be one of : list of

How to write a service to keep track of gprs data usage on android device

五迷三道 提交于 2019-12-24 08:22:11
问题 I want to write a service in android which will keep track of data usage in the background. when an event of data usage will be captured, I will save the details in local database. I read about TrafficStats class in android but it will check only once when activity gets started. I want a continuous background process running. I even found a sample project - https://github.com/commonsguy/cw-andtuning/tree/master/TrafficMonitor as mentioned in the post - How to measure data usage of my app

Passing Bluetooth device to a service, null getParcelableExtra

浪子不回头ぞ 提交于 2019-12-24 05:57:55
问题 I am trying to maintain bluetooth connection when the screen is off. So I created an app that you can discover bluetooth devices around and choose from list. Then pass the chosen bluetooth device to backgroundService class which will handle the rest.But I am getting null pointer when I try to get device from intent. Any help will be appreciated. Here is my code segments @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if(btAdapter.isDiscovering()){

Create service to detect any action from the user

十年热恋 提交于 2019-12-24 03:27:06
问题 I'm trying to create a service where I want to detect something about user, let's say when user lays the device on a table, the thing is that I have that action detected but I have it on a MainActivty and I want it to put on Service . The thing is that on my MainActivity() I had my registerAction() and on my onResume() were called and in onPause() I call the unregisterListener() from my sensor , as well I have a HandlerThread where I start it on my onCreate() how do I change it to Service ?

Android GCM Sending token to server

北城余情 提交于 2019-12-24 01:38:07
问题 The GCM Sample Project gives a stubbed out example of sending a GCM token to your server: public class RegistrationIntentService extends IntentService { ... @Override protected void onHandleIntent(Intent intent) { try { ... String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); Log.i(TAG, "GCM Registration Token: " + token); // TODO: Implement this method to send any registration to your app's servers.

How to get respective text and image from the respective recyclerview item in floaty upon clicking a button?

醉酒当歌 提交于 2019-12-24 01:04:51
问题 I'm retrieving some data from Firebase and showing it using RecyclerView . My RecyclerView has cards in it in which the text and images are getting retrieved. The card has a button on it which starts a floaty. The floaty has a ImageView and a TextView in which the image and text from the card from which the button was clicked should be shown. The problem is that when clicking that button of the first card, the floaty is getting started and showing the image and text from that respective card,