Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1081699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:12:06+00:00 2026-05-16T22:12:06+00:00

I have an Activity and Service that work together in my application. I’ve configured

  • 0

I have an Activity and Service that work together in my application. I’ve configured the service as a remote service (implemented AIDL) so it will keep running even when the Activity isn’t visible.

The service is responsible for polling a server for data and sending alert notifications when certain criteria are met. I do not want the Service to send these notifications when the Activity is visible.

Is there a way for the Service to know the status of any particular activity? Particularly an activity that is bound to it?

updated with manifest to troubleshoot permission problem:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.interact.listen.android.voicemail"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MyAppName"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MyObjectDetails"/>
        <service android:enabled="true" android:name=".MyService" />
        <receiver android:name=".MyReceiver">
            <intent-filter>
                <action android:name="com.foo.bar.EVENT"/>
            </intent-filter>
        </receiver>
    </application>
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>

The error I’m getting in Logcat:

09-17 15:33:17.881: WARN/ActivityManager(53): Permission Denial: receiving Intent { act=com.foo.bar.myobject.EVENT (has extras) } to ProcessRecord{43928b40 223:com.foo.bar.myobject/10022} (pid=223, uid=10022) requires com.foo.bar.myobject.EVENT due to sender com.foo.bar.myobject (uid 10022)
09-17 15:33:48.901: WARN/ActivityManager(53): Permission Denial: receiving Intent { act=com.foo.bar.myobject.EVENT (has extras) } to com.foo.bar.myobject requires com.foo.bar.myobject.EVENT due to sender com.foo.bar.myobject (uid 10022)

Task that sends the broadcast:

@Override
public void onStart(Intent intent, int startId)
{
    super.onStart(intent, startId);
    serviceHandler = new Handler();
    serviceHandler.postDelayed(myTask, 100L);
    Log.d(TAG, "onStart()");
}

class Task implements Runnable
{
    public void run()
    {
        Log.i(TAG, "Getting myObjects...");
        getMyObjects();
        Bundle bundle = new Bundle();
        bundle.putLongArray("ids", getIdsToUpdate());

        Intent i = new Intent();
        i.setAction(UPDATE_ACTION_STRING);
        i.putExtras(bundle);

        sendOrderedBroadcast(i, UPDATE_ACTION_STRING);

        serviceHandler.postDelayed(this, 30000L);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:12:07+00:00Added an answer on May 16, 2026 at 10:12 pm

    Is there a way for the Service to know the status of any particular activity? Particularly an activity that
    is bound to it?

    You can implement some sort of callback system.

    But there’s a cleaner way to solve the problem. Use an ordered broadcast. Have the activity have a high-priority receiver; have the raise-a-notification logic be in a low-priority receiver. Have the activity’s receiver call abortBroadcast() to prevent the notification. I have a blog post up about the technique. Use an event bus: greenrobot’s EventBus, LocalBroadcastManager, an Rx-based event bus, or even a MutableLiveData. Have the service post a message to the bus. Have the UI layer register for events on the bus when the UI is in the foreground. Have the service raise a Notification if nobody picks up the event placed onto the bus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an single Activity application that starts a Service and binds to it.
My application have a service and an activity. Sometimes the service will send a
I have an android activity and a service implemented using aidl. Works like a
I have a service that work in foreground, and when the Main activity launch
So I have an activity in an application that starts a service: private void
I have a service that also contains an activity the problem is sometimes it
I have a Service that sends an Intent to my Activity every 0.1 seconds.
I have on Service that must communicate with an Activity (MyActivity) through a BradcastReceiver.
So i have a service, that starts an activity displayed as a Popup thank's
I have an android recurring service running in background, no Activity running in front

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.