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

  • Home
  • SEARCH
  • 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 9203677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:31:32+00:00 2026-06-17T23:31:32+00:00

I am attempting to create a java service that runs outside of the system

  • 0

I am attempting to create a java service that runs outside of the system server and would be started from boot, which based on configuration can monitor an Android device and listen for broadcasts. I have not been able to find documentation on how to write a long running java service that runs as a process that isn’t started by zygote. I am trying to modify the platform and this service would be added to a custom system.img generated by rebuilding the Android source.

The service would be started similar to the script used to run am from adb.

base=/system
export CLASSPATH=$base/framework/am.jar
exec app_process $base/bin com.android.commands.am.Am "$@"

The only examples that I have found trying to add daemons have been to implement fully native services that run on the device.

Embedded Android describes Android Userspace and some of the native daemons that run there and how to create services and add them to init to start at device boot at least prior to Zygote and the System Server ect.

public class Monitor{
    public static void main(String [] args){
        new Monitor.run();
    }
    public void run(){
         Application app = new Application();
         Context con = app.getApplicationContext();
         BroadcastReceiver receiver = new BroadcastReceiver(){
             public void onReceive(Context context, Intent intent){
                 Log.i(TAG, "Received intent:"+ intent.getAction());
             }   
         }
         IntentFilter filter = new IntentFilter("android.intent.action.TIME_TICK")
    }
}

I also tried this based on a snippet of code from the ActivityManagerService.
public class Monitor{
private Context mContext;

    Monitor(){
        Looper.prepare()
        ActivityThread at = ActivityThread.systemMain();
        mContext = at.getSystemContext();
    }
    public static void main(String [] args){
        new Monitor.run();
    }
    public void run(){
         BroadcastReceiver receiver = new BroadcastReceiver(){
             public void onReceive(Context context, Intent intent){
                 Log.i(TAG, "Received intent:"+ intent.getAction());
             }   
         }
         IntentFilter  filter = new IntentFiler("android.intent.action.AIRPLANE_MODE");
         mContext.registerReceiver(receiver,filter);
    }
}

I that intents/broadcasts can be generated from the commandline using adb and am but is there anyway to receive broadcasts. Any advice or suggestion is appreciated.

  • 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-17T23:31:34+00:00Added an answer on June 17, 2026 at 11:31 pm

    The Activity manager has code to prevent non_Apps/Zygote processes from receiving broadcasts within Android. Ended up using a different approach to meet my own needs.

    public Intent registerReceiver(IApplicationThread caller, String 
    callerPackage, 
            IIntentReceiver receiver, IntentFilter filter, String 
    permission, int userId) { 
        enforceNotIsolatedCaller("registerReceiver"); 
    ... 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I attempting to take a response from a REST service that queries an instance
I'm attempting to create an infinite stream of strings from readLine calls: import java.io.{BufferedReader,
I am attempting to create a Java source file which will interface with my
I'm attempting to create a java program that will allow me access to an
I am attempting to consume a WCF web service from a Java client using
I am attempting to create a JAR based on two separate Java packages. I
I'm attempting to create a simple animation in Java that displays a blue ball
I am attempting to create an OOP friendly Java BlackJack game to progress my
I am new to Java and NetBeans , and I am attempting to create
Im attempting to create a new operator :? on lists, which operates the same

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.