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 7990575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:03:33+00:00 2026-06-04T13:03:33+00:00

I’ve looked at the numerous posts on sending messages from services to activities, but

  • 0

I’ve looked at the numerous posts on sending messages from services to activities, but I just can’t get this to work. My receiver is never being called. Does it matter if the Activity is not in the foreground?

Here is my scenario – I am running a web server as a service. When the web server receives a URL with link to a playlist, I need to send a message to my Activity that is acting as a media player. The media player will read the playlist and start playing the songs, videos, etc in order.

I don’t want the service to start new instances of the media player activity, as sometimes it may be sending commands like fast forward or pause.

From my web server service:

private void sendMessage() {


  Log.d("juice NonoHTTPD sender", "Sending message from Hub Web Server to Hub Player");

  Intent intent = new Intent();
  intent.putExtra(HubPlayer.ACTIVITY_PARAM_HOST, sAppHost);
  intent.putExtra(HubPlayer.ACTIVITY_PARAM_PORT, sAppPort);
  intent.putExtra(HubPlayer.ACTIVITY_PARAM_TYPE, sAppType);
  intent.putExtra(HubPlayer.ACTIVITY_PARAM_URL, sAppPath);    
  intent.setAction("com.jigawattlabs.hubplayer.play");
  appContext.sendBroadcast(intent);
}

From my activity:

public class HubPlayer extends Activity implements
OnBufferingUpdateListener, OnCompletionListener,
OnPreparedListener, OnVideoSizeChangedListener, SurfaceHolder.Callback 
{
private IntentFilter intentFilter = new IntentFilter("com.jigawattlabs.hubplayer.play");

MyBroadcastReceiver mReceiver = new MyBroadcastReceiver();

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    setContentView(R.layout.mediaplayer_2);

    registerReceiver(mReceiver , intentFilter);

}

public class MyBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        extras = intent.getExtras();

        sHost = extras.getString(ACTIVITY_PARAM_HOST);
        sPort = extras.getString(ACTIVITY_PARAM_PORT);
        sType = extras.getString(ACTIVITY_PARAM_TYPE);
        sXMLURL = extras.getString(ACTIVITY_PARAM_URL);

        DebugMsg("received broadcast in MyBroadcastReceiver.");
        processInputRequest();
    }
}
}

Even though it doesn’t seem necessary to put this in the manifest since I’m registering the BroadcastReceiver within my code, I also added an intent filter:

    <activity android:label="Media Hub Player" android:launchMode="singleTask"
        android:screenOrientation="unspecified"
        android:name=".HubPlayer" >
        <intent-filter>
            <action android:name="com.jigawattlabs.hubplayer.play" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>            
    </activity> 

Thanks in advance.

  • 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-06-04T13:03:35+00:00Added an answer on June 4, 2026 at 1:03 pm

    OK, I have a workaround for this, but I was hoping for something better. Here is what I did

    • If the service needs to send a message to an activity, it checks to see if the activity is running
    • If the activity is running, it does the sendBroadcast as above
    • If the activity is not running, I do a StartActivity and pass it the same info as I would with sendBroadcast
    • From the activity, I pick up the intent either from the registered BroadcastReceiver or from the intent passed on onResume (if StartActivity is called).

    Here is the code to check if an activity is running

    public boolean isHubRunning() 
    { 
        boolean isServiceFound = false;
    
        ActivityManager activityManager = (ActivityManager)appContext.getSystemService (Context.ACTIVITY_SERVICE); 
        List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE); 
        isServiceFound = false; 
        for (int i = 0; i < services.size(); i++) 
        { 
            //DebugMsg(services.get(i).topActivity.toString());
            if (services.get(i).topActivity.toString().contains("juicemediahub.HubPlayer")) 
            {
                isServiceFound = true;
            }
        } 
        DebugMsg("Hub Player Running = " + String.valueOf(isServiceFound));
        return isServiceFound; 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.