android-service

Syncing a REST service with an android app

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 03:29:12
There's a REST service that I use to populate info in my database, that is later used by my app. I've read several threads on the matter, and now have to decide how I want the sync between the REST service and my DB to work. Think of an app that gets info from google finance APIs about stocks and stores it in a DB, displays the information when the app is launched, and sends notifications when specific events happen in the stock price. I already implemented the simple option of AsyncTask that is launched when a user manually requests a sync. Now I have to implement the auto-sync and these are

Subscribing or binding to an existing Intent service

て烟熏妆下的殇ゞ 提交于 2019-12-04 03:26:36
问题 I have an app that has an initial activty that list some files within a list view. When an item is clicked within the list it takes you to a detail activity of that specific file. In the detail view I have a button called download, when you click on download it starts a IntentService which sets off the file to be downloaded as such: downloadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(AppDetailsActivity.this, AppDownloadService

Bind Service to BroadcastReceiver

Deadly 提交于 2019-12-04 03:06:39
问题 I have some Service class, which registers multiple alarms. In my BroadcastReceiver class, I want the onReceive () method to call some method of the Service class. However, I don't see how I can bind them together. I tried to make the BroadcastReceiver an inner class, but then I got more errors and couldn't fire the alarm at all. Thanks 回答1: Look at http://developer.android.com/reference/android/content/BroadcastReceiver.html life cycle. BroadcastReceiver is created only for handling a

Is the Android service still alive even after the onDestroy() be called?

岁酱吖の 提交于 2019-12-04 03:02:23
For studying the Android service, I wrote a test program that have three button "bind service", "unbind service" and "send echo" on the screen. When clicked, they use bindService() , unbindService() and a Messenger to communicate with the service. Here is the service codes: public class MessengerService extends Service { private final Messenger mMessenger = new Messenger(new TempHandler()); private class TempHandler extends Handler { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_SAY_HELLO: Toast.makeText(getApplicationContext(), "Hi, there.", Toast.LENGTH

Android: How to resolve Google API connection fail from a Service?

可紊 提交于 2019-12-04 02:47:31
here is the code provided by the official guide, while this is a snippet causing problems. @Override public void onConnectionFailed(ConnectionResult result) { if (mResolvingError) { // Already attempting to resolve an error. return; } else if (result.hasResolution()) { try { mResolvingError = true; result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR); } catch (IntentSender.SendIntentException e) { // There was an error with the resolution intent. Try again. mGoogleApiClient.connect(); } } else { // Show dialog using GooglePlayServicesUtil.getErrorDialog() mResolvingError = true;

Android background services and alarms

折月煮酒 提交于 2019-12-04 02:07:50
问题 Recently encountered with a problem when Android 4.4 killed my app's Service and AlarmManager when device going into a sleep mode ( START_STICKY param doesn't helps). I tried a lot of things, but nothing works as I need. In my task manager app I always see a lot of processes of non-default apps such as Google+, Skype, Google Drive end some else that working in real time and never were killed by the system. I want to ask more experienced developers how to create Service or Alarm that will not

Service run on specific Time Android

送分小仙女□ 提交于 2019-12-04 01:59:55
问题 I am trying to run service on every day only on Specific time, lets say every day 8 :00 am and here I found two methods as public static void setScheduleMessage(Context context, int hours, int minuts, int seconds) { Calendar calendar = Calendar.getInstance(); // 8 AM calendar.set(Calendar.HOUR_OF_DAY, hours); calendar.set(Calendar.MINUTE, minuts); calendar.set(Calendar.SECOND, seconds); PendingIntent pendingIntent = PendingIntent.getService(context, 0, new Intent(context,

How to use NotificationCompat.Builder and startForeground?

时光怂恿深爱的人放手 提交于 2019-12-04 01:37:04
Short question: I'm trying to use the NotificationCompat.Builder class in order to create a notification that will be used for the service, but for some reason, i either don't see the notification, or can't cancel it when the service should be destroyed (or stopping from being in the foreground) . my code: @Override public int onStartCommand(final Intent intent, final int flags, final int startId) { final String action = intent == null ? null : intent.getAction(); Log.d("APP", "service action:" + action); if (ACTION_ENABLE_STICKING.equals(action)) { final NotificationCompat.Builder builder =

How to correctly handle startForegrounds two notifications

我是研究僧i 提交于 2019-12-04 01:00:01
问题 I have an IntentService that uploads a file. Everything works fine, but I'm a little confused about how to handle the notifications. When I start the notification I use startForeground() because the files can be rather large and I don't want the upload to get killed unless absolutely necessary. When I use startForeground() it displays two notifications in the notification area (one under Ongoing and one under Notifications): I've read through a number of different Stack Overflow posts and web

Throwable: Failed to create the SD card

雨燕双飞 提交于 2019-12-04 00:15:07
问题 PLEASE HELP. My AVD is not running as I have posted at AVD not running. I tried to create a new AVD but get this error Throwable: Failed to create the SD card. How to solve this? Really need help seriously...Thanks 回答1: Whats your logcat throws Throwable: Failed to create the SD card. At First you need to download the Android SDK, launch the Android SDK Manager , install the Android SDK Platform-tools . Then check Install Intel HAXM .I hope it will helps you . 回答2: EmptyThrowable: Failed to