android-service

Repeating Alarm Manager After reboot

放肆的年华 提交于 2019-11-27 16:18:23
i want to create broadcast AlarmManager(repeating) with Notification message.i pass my calender object from Pickers. If i don't reboot my device it works normally. However, when i reboot my device,as you know my calander object will be null. How can i manage my repeating alarm after rebooting and how can i hold my Calendar schedules? Thanks for your ideas. public class MyReceiver extends BroadcastReceiver { private static final int PERIOD = 10000; final public static String ALARM_ID = "AlarmId"; final public static String NOTIFICATION_ID = "NotificationId"; @Override public void onReceive

Android 9 (Pie), Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord

旧时模样 提交于 2019-11-27 16:11:31
问题 First of all, I looked at these; Context.startForegroundService() did not then call Service.startForeground() Context.startForegroundService() did not then call Service.startForeground Android 9 (Pie) Only: Context.startForegroundService() did not then call Service.startForeground() - Works fine on Oreo RemoteServiceException Context.startForegroundService() did not then call Service.startForeground() https://issuetracker.google.com/issues/76112072 I have a streaming application used by

Difference between START_STICKY and START_REDELIVER_INTENT?

◇◆丶佛笑我妖孽 提交于 2019-11-27 15:56:10
问题 I am creating a service for my android app, providing data to the service via Intents. The problem is that when the service is destroyed by the system than the intent data provided to it can't be restored, as a result of which my app crashes. I have heard START_REDELIVER_INTENT will restart my service as soon as there is sufficient memory available restoring the intent data provided to service whereas the START_STICKY will not restore the intent data. am i right ? or is there something I don

part-1 persistent foreGround android service that starts by UI, works at sleep mode too, also starts at phone restart

自作多情 提交于 2019-11-27 15:00:02
问题 Status:--- I equally accept Karakuri's and Sharad Mhaske's answer , but since Sharad Mhaske answer after the start of bounty , the bounty should go to him. Part-2 made: part-2 persistent foreGround android service that starts by UI, works at sleep mode too, also starts at phone restart In stack overflow , only one answer may be accepted . I see both answers as acceptable but one has to be chosen (I chosed at random). Viewers are invited to up/down vote answers/question to appreciate the

Service being re-Created by AlarmManager

坚强是说给别人听的谎言 提交于 2019-11-27 14:55: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 = (AlarmManager)getSystemService(ALARM_SERVICE); // do onCreate stuff } @Override int onStartCommand

Register GCM from a library project

天大地大妈咪最大 提交于 2019-11-27 14:32:20
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 my test project manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas

Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

别来无恙 提交于 2019-11-27 14:16:12
I am trying to post a notification with a custom view in the notification area from an IntentService , and getting the Couldn't expand RemoteView error. Here's what I am doing in onCreate() : mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); icon = R.drawable.icon; tickerText = "data upload in progress"; contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notiflayout); contentView.setImageViewResource(R.id.image, R.drawable.icon); contentView.setTextViewText(R.id.text, "Hello"); contentView.setProgressBar(R.id.progressBar,

Android O - Detect connectivity change in background

你。 提交于 2019-11-27 13:41:30
First off: I know that ConnectivityManager.CONNECTIVITY_ACTION has been deprecated and I know how to use connectivityManager.registerNetworkCallback . Furthermore if read about JobScheduler , but I am not entirely sure whether I got it right. My problem is that I want to execute some code when the phone is connected / disconnected to/from a network. This should happen when the app is in the background as well. Starting with Android O I would have to show a notification if I want to run a service in the background what I want to avoid. I tried getting info on when the phone connects /

Detect Lock Screen Incorrect Password by user in Android

会有一股神秘感。 提交于 2019-11-27 13:20:05
问题 I am building a security app and I need to know if the user is giving incorrect password . Suppose user phone is locked by pattern lock system , and unfortunately user has forgotten the pattern password.When user give wrong pattern 5 time, there will be a penalty for 30 sec . I need to catch that penalty event . In my app, i have to do some task (for the safety of user) when this even come . Please help me, 回答1: You can set up a DeviceAdminReceiver that will be notified about failed password

How to display Toast from a Service after main Activity finishes?

与世无争的帅哥 提交于 2019-11-27 13:09:56
问题 UPDATE: I don't agree that this is a duplicate - because I am seeking for a way to exit the main app and still show a Toast from the service. In a very simple test app I have 2 buttons: Clicking any of the buttons will run a service with a corresponding action string ("open" or "flash") - OpenActivity.java: public class OpenActivity extends Activity { private Intent mServiceIntent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R