android-service

Notification from IntentService - NullPointerException while obtaining Context

☆樱花仙子☆ 提交于 2019-12-01 16:42:08
I am unable to generate the notification (in the notification area) from an IntentService . I get a NullPointerException while obtaining NotificationManager . The problem is with Context. 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): Caused by: java.lang.NullPointerException 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): at android.content.ContextWrapper.getSystemService(ContextWrapper.java:363) 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): at com.Android.Main1.FileUploaderService.<init>(FileUploaderService.java:71) The line of code is: mNotificationManager = (NotificationManager)

Notification from IntentService - NullPointerException while obtaining Context

青春壹個敷衍的年華 提交于 2019-12-01 15:27:58
问题 I am unable to generate the notification (in the notification area) from an IntentService . I get a NullPointerException while obtaining NotificationManager . The problem is with Context. 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): Caused by: java.lang.NullPointerException 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): at android.content.ContextWrapper.getSystemService(ContextWrapper.java:363) 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): at com.Android.Main1.FileUploaderService.

How to communicate between background services

对着背影说爱祢 提交于 2019-12-01 13:34:59
I am implementing an app, in that I have two Services. One does some task and pass some value to another service and that service does some task using this value. When the first Service generate first value it should start 2nd service. Here after the values generated by the first service will be added in a queue in 2nd service. First time when the 2nd service starts I can set the value in queue using intent, but I don't know how to communicate after starting the 2nd service. How to communicate between these to services. Anybody have some idea on this please do help me. As of my understanding,

How to solve error “Default Activity Not Found” occurred when starting my application from Service?

你离开我真会死。 提交于 2019-12-01 13:08:23
I need to start my Android Application using Service and after start an Activity from that Service . Firstly I created Sample Application by referring Stack Overflow . I created StartReceiver class to start Service . public class StartReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent arg1) { Intent intent = new Intent(context,MyService.class); context.startService(intent); Log.i("Autostart", "started"); } } This is my Service class. public class MyService extends Service { private static final String TAG = "MyService"; @Override public IBinder onBind(Intent

How to stop my service?

前提是你 提交于 2019-12-01 12:35:53
Please also see Edit 2 (below) I have extended NotificationListenerService and implemented several of its methods including the onDestroy() method (but not the onBind() or onStartCommand() method, as I don't need them, as far as I know). However when I call selfStop() onDestroy() isn't called. I know there are other links out there about calling selfStop() , but I haven't found any solution for my problem. My service is started by the system using the following code in the android-manifest : <service android:name=".NotificationListener" android:label="@string/service_name" android:permission=

Exception on getSystemService(Context.AUDIO_SERVICE)

♀尐吖头ヾ 提交于 2019-12-01 12:11:53
I wanted to create an app that drops an incoming call based on some settings, that seems to be impossible on Android 1.6. So I decided to write an app that changes the Ringer to mute when the call would've been dropped. The thing is that when I call getSystemService(Context.AUDIO_SERVICE) I get an exception. These are my classes: CallReceiver public class CallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { MyPhoneStateListener phoneListener = new MyPhoneStateListener(); TelephonyManager telephony = (TelephonyManager)context

Where should I request location updates in A service?

柔情痞子 提交于 2019-12-01 12:08:15
问题 I have a service checking for location updates I am confused in requesting location updates! Should I have to call requestLocationUpdates() in onCreate() of the service or in the onStartCommand() of the service? 回答1: Here is my code that worked for me! Don't forget to add mgoogleApiClient.connect() in onCreate() and then take a look at the onConnected Method of googleapiClient - here I've created the the LocationRequest with LocationServices.FusedLocationApi.requestLocationUpdates(

How to show an actitivity only when an app widget is first created?

别等时光非礼了梦想. 提交于 2019-12-01 12:06:52
My app widget needs to be configured when it first added to the home screen. I want to open a configuration view right after the user adds the widget. AppWidgetProvider has no onCreated event, so I'm showing the confugration activity on the onUpdate event, and store a boolean value in SharedConfiguration that marks that the configuration has already been shown. Is there an easier way? In the AppWidgetProvider XML file there is an attribute called android:configure You can use this to point to an Activity to launch when the app is dropped onto the home screen. ex: <?xml version="1.0" encoding=

How to solve error “Default Activity Not Found” occurred when starting my application from Service?

风流意气都作罢 提交于 2019-12-01 12:02:06
问题 I need to start my Android Application using Service and after start an Activity from that Service . Firstly I created Sample Application by referring Stack Overflow . I created StartReceiver class to start Service . public class StartReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent arg1) { Intent intent = new Intent(context,MyService.class); context.startService(intent); Log.i("Autostart", "started"); } } This is my Service class. public class MyService

BroadcastReceiver issues in Android 3.1+

自闭症网瘾萝莉.ら 提交于 2019-12-01 11:30:43
I'm trying to update location data to a web database using BroadcastReceiver and Service . However I am having difficulties making it to work with Android 3.2 on a Galaxy Tab 7.0 Plus. The same application is working very well on a Android 2.3.6 Galaxy Note, but it doesn't run on the tablet. In fact, I add the RECEIVE_BOOT intent action to my receiver, but it never gets instantiated, that is, o nReceive() never gets called after boot completes. I wonder if there are any updates to the system that cause this action. Here is my xml and receiver classes: AndroidManifest.xml <manifest xmlns