android-service

Restart the service even if app is force-stopped and Keep running service in background even after closing the app How?

不打扰是莪最后的温柔 提交于 2019-11-27 03:42:00
I am trying to run a service in the background. What my app does is when user checks checkbox then service starts and when it is unchecked service is stopped. Which is working perfectly fine. But the problem is when I closed the app from task manager it then also stops the service. What I want is to keep the service running even after it is close from task manager. Then only way to stop that service is by user himself by unckecking the box. How can I achieve this? Here is my code My main activity public class SampleServiceActivity extends Activity { /** Called when the activity is first

NotificationListenerService Implementation

隐身守侯 提交于 2019-11-27 03:36:11
I am trying to implement NotificationListnerService which is added in android 4.3 but I am not able to get the notification details. My code are as below public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setSmallIcon(R.drawable.ic_launcher); mBuilder.setContentTitle("notification test"); mBuilder.setContentText("Notification text"); mBuilder.setAutoCancel(true); Intent

Unable to start service Intent: not found

為{幸葍}努か 提交于 2019-11-27 03:04:11
问题 I've the same issue described here but i can't understand whats wrong. My issue is: Unable to start service Intent { act=.connections.MoodyService } U=0: not found EDIT I've changed my package from connections to service in the source code, sorry for the confusion My manifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.moody" android:installLocation="auto" android:versionCode="0" android:versionName="0.6.7 alpha" > <uses-sdk android

Can I get data from shared preferences inside a service?

白昼怎懂夜的黑 提交于 2019-11-27 03:01:34
问题 I'm developing an android application. I'm using android 2.2 In my application I am capturing GPS data and sending it to service with the 1 hour time interval. If user exits from application it's also working (it is required). I'm using 2 services (User defined), one for capturing GPS data and other for sending to the server. Here my doubt In service, can we use shared preferences. If we store any data in shared preferences in any activity of the application, will we be able to use that data

Concurrent writing to android database (from multiple services)?

妖精的绣舞 提交于 2019-11-27 02:22:56
问题 I've a serious problem with android sqlite database and concurrent writing. For better explanations, I will give you a real life example: I've an desktop widget, where I'm showing a list of items from my database (and on background I have DataService, which in regular intervals collects fresh data from my remote server, and update my database with them). So - when i click on some item in list, i need to update clicked item (=do write operation) in database. BUT when i click on item exactly in

How to restart service in android to call service oncreate again

蹲街弑〆低调 提交于 2019-11-27 02:08:53
问题 I have a service in my Android Application which runs always.Now i have a settings from my server through GCM and update these settings to my service. I put my settings in oncreate of service. So i need to restart my service to fetch latest settings. How to restart my service? 回答1: Call this two methods right after each other, which will causes the Service to stop and start. Don't know any method that "restarts" it. This is how I have implemented it in my application. stopService(new Intent

Android Service interacting with multiple activities

拥有回忆 提交于 2019-11-27 02:02:23
问题 I'm trying to refactor/redesign an Android app. Currently, I've one UI activity ( Activity 1 ) that creates a DataThread . This thread is responsible for network I/O and interacts (provides data) with the UI activity via a handler . Now, I want to add another activity (a new UI screen with Video) - Activity 2 . Activity 1 is still the main activity. Activity 2 will be invoked when the user clicks a button on Activity 1 . Activity 2 's data also comes from the DataThread . My idea is to put

Check if service is running on Android?

六月ゝ 毕业季﹏ 提交于 2019-11-27 01:23:16
问题 l want to check if a service is running l wrote this code public class startServiceOrNo { public static void startServiceIfItsNotRuning(Class<?> class1, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (class1.getName().equals(service.service.getClassName())) { Lg.d("servisstart SERVICE ALREADY START" + class1.getName()); return; } } Lg.d(

USSD service not working

耗尽温柔 提交于 2019-11-27 01:07:41
问题 I'm trying to develop an application which silently dismiss the USSD responses. I've used the code from http://commandus.com/blog/?p=58 with minor changes. I've created the IExtendedNetworkService.aidl in the package com.android.internal.telephony and USSDDumbExtendedNetworkService inside the package com.commandus.ussd . The problem is, nothing happens after running the application (even after restarting the phone). Can someone point out what am I doing wrong? Should I write any additional

Internet listener Android example

喜欢而已 提交于 2019-11-27 00:46:18
I am working on an Android app that will continuously remain connected to Internet. If Internet is dow, it should give an appropriate message to the User. Is there any thing like Internet Listener? Or how to implement this event that whenever Internet connection is not available it should give alert. Chirag Create one Broadcast Receiver for that and register it in manifest file. First create a new class NetworkStateReceiver and extend BroadcastReceiver. public class NetworkStateReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Log.d("app","Network