NotificationListenerService Implementation
You need to grant access to your app to read notifications: “Settings > Security > Notification access” and check your app.
You need to grant access to your app to read notifications: “Settings > Security > Notification access” and check your app.
Sure! No reason you cannot have an application with only a service. …and no need to get into AIDL unless you want to. The problem is, how to make the application run. When you create an application with an Activity, you add an Intent filter, in the manifest, that makes the activity startable from the … Read more
This is not how you should register a receiver. You receiver stops working, because you construct it in onCreate, which means it will live as long as your app is alive. When the app gets destroyed, you also lose the the receiver. If you register receiver inside an activity, you should always register it in … Read more
This is how I did it. Of course, you need to pass appropriate context. Handler h = new Handler(context.getMainLooper()); h.post(new Runnable() { @Override public void run() { Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } });
Second edit: I’m now using firebase’s JobDispatcher and it works perfect across all platforms (thanks @cutiko). This is the basic structure: public class ConnectivityJob extends JobService{ @Override public boolean onStartJob(JobParameters job) { LogFactory.writeMessage(this, LOG_TAG, “Job created”); connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { connectivityManager.registerNetworkCallback(new NetworkRequest.Builder().build(), networkCallback = new ConnectivityManager.NetworkCallback(){ // -Snip- }); }else{ … Read more
Swiping the app from the recent tasks list actually kills the operating system process that hosts the app. Since your service is running in the same process as your activities, this effectively kills the service. It does NOT call onDestroy() on the service. It just kills the process. Boom. Dead. Gone. Your service does not … Read more
I used ViewModel with LiveData in LifecycleActivity and Fragments it works and observes data as expected. Coming to your problem, when you create new ViewModel from Service or any another Activity it creates new instance of all the LiveData and other dependencies required for ViewModel to query from Repository and ultimately DAO. If you are … Read more
Echoing previous response, you shouldn’t use a broadcast receiver. In the same situation, what I did was to declare the theme thusly: <activity android:name=”MyActivity” android:label=”@string/app_name” android:theme=”@android:style/Theme.NoDisplay”>
Bound Service A service is bound when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC). When the last client unbinds from the service, the system … Read more