android-service

Android Repeating Alarm invoking a service

非 Y 不嫁゛ 提交于 2019-12-11 04:18:53
问题 I am trying to send GPS coordinates to server in every 1 minute interval through a background service . It invokes the service for thee first time but it doesn't repeat it . Code for setting the alarm: Intent gpsIntent = new Intent(CheckInActivity.this, GoogleMapService.class); gpsPendingIntent = PendingIntent.getService(CheckInActivity.this, 0, gpsIntent, 0); AlarmManager alarmManager_gps = (AlarmManager)getSystemService(ALARM_SERVICE); Calendar calendar_gps = Calendar.getInstance();

Android foreground service being killed under certain conditions

心已入冬 提交于 2019-12-11 04:14:34
问题 I have a Service used for playing audio. It is created with START_STICKY , and calls startForeground() when it is told to play music, and stopForeground() when it is told to stop playing music. The service continues to run fine and play music, even after the app is swiped out of the task manager on 4.2.1. However, the service is inexplicably killed if the app is swiped out and the app's home/lockscreen widget is interacted with or if I try to sendBroadcast() within the service. I cannot find

Track Gps At every 10 minutes using timer in android

久未见 提交于 2019-12-11 04:12:55
问题 I am developing an android application and I am using a service that tracks location via GPS every 10 minutes. But when I put the location listener in a timer task, it throws an exception: Cannot put code inside thread that has not called looper.prepare() . Does anyone have any insight on this problem? 回答1: You need not to start a service for recieving locationUpdate every 10 min instead do something like this mLocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

Exact time for custom notifications in Android

故事扮演 提交于 2019-12-11 04:03:37
问题 I am developing an Android application for counseling services. Client can view their scheduled appointment in app. For example, Next appointment: Dec 31 2016 10:00AM Now I need to do that user will receive 2 notifications – reminders about appointment. One on 7 days before and another on 3 days before. I save this date (Dec 31 2016 10:00AM) as a String so I can extract year, month, etc. I found that I need to write some kind of service which will send these notifications. This is what I

Access SharedPreferences from another class (non-activity)

落花浮王杯 提交于 2019-12-11 03:56:16
问题 I'm trying to pass the values from the MainActivity class into SMSReceiver class using SharedPreferences but the values that returned isn't true i used this and this but it seems it doesn't work Edit : i'm using a service in my program so i can't call the members like MainActivity.MyPREFENRECES, SMSreceiver.rK because after i kill the activity i get null exception Edit I'm calling the method run in the layout any help please ?? MainActivity.java import android.content.SharedPreferences;

StartForeground Bad Notification Error

[亡魂溺海] 提交于 2019-12-11 03:49:07
问题 I am trying to use a while loop in order to update a notification every second. However on 2.3.3 & below, it crashes with these logcat errors: 08-14 07:30:17.394: E/AndroidRuntime(501): FATAL EXCEPTION: main 08-14 07:30:17.394: E/AndroidRuntime(501): android.app.RemoteServiceException: Bad notification for startForeground: java.lang.IllegalArgumentException: contentIntent required: pkg=com.package.name id=77 notification=Notification(vibrate=null,sound=null,defaults=0x4,flags=0x40) The

KitKat: Service is null after exiting main activity

我的梦境 提交于 2019-12-11 03:43:53
问题 I have a service and I need to check if it's still running after some time from a static context. [I noticed this happens only on Android KitKat] What I did: My service: public class Servizio extends Service { public static Service servizio; [...Other things...] @Override public void onCreate() { super.onCreate(); servizio = this; scheduleMyAlarmToDoSomethingAfterSomeTime(); } [...Other things...] } Then I launch the service from the main Activity in onCreate : @Override protected void

Permission in calling service from another app

。_饼干妹妹 提交于 2019-12-11 03:38:34
问题 Possible Duplicates: Permission for services, Permission issue while starting a service from android, Exported service does not require permission: what does it mean?, Not allowed to start service Intent without permission etc I have two applications say App "A" and App "B". App A has one service with custom permission and App B wants to call that service. Following is my code snippet App A: : Manifest File <service android:name="SendService" android:permission="android.permission.MyService">

Updating Ui Components in Activity based on MediaPlayer object from Service While Playing music files in background

99封情书 提交于 2019-12-11 03:32:33
问题 I am creating an Android music player based on the tutorial from Android Hive here is the link. http://www.androidhive.info/2012/03/android-building-audio-player-tutorial/ Which is tutorial for creating an music player like this. Now I have successfully created my customized music player using this tutorial but their is a problem in that i.e. it doesn't play music in background. So searched for it and found this post Playing BG Music Across Activities in Android and I have found that I have

Background Service to take picture with Camera

那年仲夏 提交于 2019-12-11 03:31:33
问题 I know there are a lot of questions regarding this, but i think the problem i am facing is not addressed in any of them. From all the different questions i wrote this Service. The problem is that i am getting "Success" in all the try-catch blocks in the onStartCommand method, but the logs in the Callback methods (ShutterCallback and PictureCallback) are not getting processed. Which I think means that the picture is taken but the Callbacks are not called, which is weird. Camera cam; Parameters