android-service

Shared preferences between two processes of the same application

ⅰ亾dé卋堺 提交于 2019-11-26 18:13:24
问题 I'm writing an Android app that contains both UI and separate processes running. I want to share simple information between the main process and a service defined in my application that is executed in a different process. I find to messy to use AIDL for inter-process communication for this purpose. The question is: Is it safe to use Shared Preferences of the application for communicating between this two processes? This is: both read and write the same shared preferences. I'm wondering if it

Android service crashes after app is swiped out of the recent apps list

一曲冷凌霜 提交于 2019-11-26 18:09:37
问题 I have a service that gets started (not bound) by an activity. If the activity gets destroyed (e.g. by pressing the back button), the service continues to run, this is of course intended. However, if I swipe the activity out of the 'recent apps' list, the service gets restarted immediately. This is reproducible, every time the activity/app is swiped out of the list, there is a new call to the service's onCreate-method. No call to onDestroy in between! First I thought the service gets killed

How to keep a service running in background even after user quits the app? [closed]

时光毁灭记忆、已成空白 提交于 2019-11-26 17:47:46
问题 I am developing an app where I start a service if a particular feature (in my app) is enabled by user. I want to keep running this service even after user quits my app. How can I do this? plz help 回答1: Right from developer.android.com A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a

Reasons that the passed Intent would be NULL in onStartCommand

时间秒杀一切 提交于 2019-11-26 17:40:15
问题 Is there any other reason that the Intent that is passed to onStartCommand(Intent, int, int) would be NULL besides the system restarting the service via a flag such as START_STICKY ? Also, when the service is restarted by the system the Intent.getAction() method returns NULL... sometimes. Intent is not NULL just getAction() I asked here too but haven't received an answer just yet. UPDATE : After chatting with Mark Murphy, he suggested that I return START_REDELIVER_INTENT in the onStartCommand

How to run an android app in background?

好久不见. 提交于 2019-11-26 17:36:08
This code will run an app automatically after booting the system, but the app will close after pressing the back button. If the app is run normally by clicking it's icon. It will continuously run even after pressing the back button or running other apps. public class AutoBoot extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent i = new Intent(context, MyActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } } My question is, how to make this auto run code to continuously run even after pressing the back button or

NotificationListenerService Implementation

可紊 提交于 2019-11-26 17:31:40
问题 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(

Continue Service even if application is cleared from Recent app

旧时模样 提交于 2019-11-26 17:11:02
I am having a little issue. In my application, a Service is started after user is logged in successfully. Previously, the service needed to stop if application was killed. (say, removed from Recent application list by swiping.) So we had used android:stopWithTask="true" . Now we need the Service to run as it is, even if the Task which started it, is removed from Recent app list. So I changed the Service to include android:stopWithTask="false" . But that doesn't seem to work. Related code: Here is manifest part related to Service: <service android:enabled="true" android:name=".MyService"

Service being re-Created by AlarmManager

喜你入骨 提交于 2019-11-26 16:57:27
问题 I have a fairly standard Service which I wish to trigger using an alarm. Here's the initiation section of the service: class MyService extends Service { private Context context; private AlarmManager alarmManager = null; private final String startReason = "com.stuff.myreason"; private final int REASON_NO_INTENT = 0; private final int REASON_ALARM = 1; private final int REASON_X = 2; // and so on. @Override void onCreate() { super.onCreate(); context = getApplicationContext(); alarmManager =

Register GCM from a library project

醉酒当歌 提交于 2019-11-26 16:47:45
问题 I am trying to register to GCM from a library project the GCMIntentService is defined inside the library project. Here is my registration code(inside the library project): public static void init(Context context, String id){ GCMRegistrar.checkDevice(context); GCMRegistrar.checkManifest(context); GCMRegistrar.register(context, id); } But the callbacks of the GCMIntentService are not being called, they are being called only when I run the library project as standalone android project. Here is

ANDROID: email client receiver email id empty in android-parse

瘦欲@ 提交于 2019-11-26 16:43:46
I'm using android- parse server in app. below is parse db screenshot of email column . the email column is after the hidden password column in database . my problem is when i retrieve email ids to email client, email is null even if the email column has emails . note : in the app in another place (another table) i'm pulling email ids to email client in same manner, but there mail is showing well .. only here the problem occurs. if anyone knows please help ? this is email column in parse database try{ JSONObject jsonObject = parseObjectToJson(object); Log.d("Object", jsonObject.toString()); Log