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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:00:21+00:00 2026-05-28T06:00:21+00:00

How to start a service in android using nested class when mobile is switched

  • 0

How to start a service in android using nested class when mobile is switched ON?

I have the package contains nested class.

package Name

com.android

  1. MainActivity
  2. BroadCastReceiver

I am trying to reboot my BroadCast receiver. But it doesn’t work (getting Failed). I don’t know if the reason is, because of any problems for nested classes.

 <receiver android:name="ConnectionReceiver"></receiver> 

<receiver android:name="com.android.MainActivity .BroadCastReceiver "> 
<intent-filter> 
<action android:name="android.intent.action.BOOT_COMPLETED" /> 
</intent-filter> 
</receiver> 
  • 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-28T06:00:22+00:00Added an answer on May 28, 2026 at 6:00 am

    manifest file

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="onchip.automobile.caraccessory1"
        android:versionCode="1"
        android:versionName="1.0" >    
    
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
    
            <receiver 
                android:name=".Onchip_BroadcastReceiver">
                <intent-filter >
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                    <category android:name="android.intent.category.HOME" />
                </intent-filter>            
            </receiver>
    
            <service 
                android:name=".Onchip_BackgroundService">
                <intent-filter >
                    <action android:name="onchip.automobile.caraccessory1.BACKGROUND_SERVICE" />                
                </intent-filter>            
            </service>
        </application>
    
    </manifest>
    

    Onchip_BroadcastReceiver.java

    package onchip.automobile.caraccessory1;
    
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    
    
    public class Onchip_BroadcastReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            Intent serviceIntent = new Intent("onchip.automobile.caraccessory1.BACKGROUND_SERVICE");        
            context.startService(serviceIntent);
        }   
    }
    

    Onchip_BackgroundService.java

    package onchip.automobile.caraccessory1;
    
    import android.app.Service;
    import android.content.Context;
    import android.content.Intent;
    import android.content.IntentFilter;
    import android.os.Bundle;
    import android.os.IBinder;
    import android.widget.Toast;
    
    
    public class Onchip_BackgroundService extends Service {
    
        @Override
        public IBinder onBind(Intent intent) {
            return null;
        }
    
        @Override
        public void onCreate() {
            super.onCreate();
            Toast.makeText(this, "Onchip_BackgroundService Created", Toast.LENGTH_LONG).show();
    
        }
    
        @Override
        public void onStart(Intent intent, int startId) {
            super.onStart(intent, startId);
            Toast.makeText(this, "Onchip_BackgroundService Started", Toast.LENGTH_LONG).show();
        }
    
        @Override
        public void onDestroy() {
            super.onDestroy();
            Toast.makeText(this, "Onchip_BackgroundService Destroyed", Toast.LENGTH_LONG).show();
        }      
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am trying to start the android browser from a service using this
I am successfully able to start my Android app automatically on boot using BroadcastReceiver
I am trying to start a service from the command line using net start
Hai tried to get the latitude and longtitude value using service class.my service function
I am new to android.. just started writing service using activity.. i want to
I have been using Titanium for an Android application that does some microblogging through
I have a class which extends android.app.Application , which I use to persist global
I am getting confused with all the different terminology when using Android: Activity, Service...
I'm new to this android. i'm using a service to do some background work.
I have developed a Service which will start when I receive the ON_BOOTUP_COMPLETED intent,

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.