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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:37:35+00:00 2026-05-30T10:37:35+00:00

I am currently trying to make a broadcast receiver which will invoke after android

  • 0

I am currently trying to make a broadcast receiver which will invoke after android device boots and then will run a background service. I have tried many examples but don’t know where I’m going wrong. I am following this example:
https://github.com/commonsguy/cw-advandroid/tree/master/SystemEvents/OnBoot
I have imported this whole project in my workspace and tried to run. But the receiver didn’t invoked or so.
Please help me out.
My Testing Device is: Motorolla Xoom with ICS 4.0.3

EDIT

Manifest

<uses-sdk android:minSdkVersion="8" />

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true" />

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REBOOT" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <service
        android:name="awais.soft.MyService"
        android:enabled="true" >
        <intent-filter>
            <action android:name="awais.soft.MyService" >
            </action>
        </intent-filter>
    </service>

    <receiver android:name="awais.soft.ServicesDemoActivity" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" >
            </action>

            <category android:name="android.intent.category.HOME" >
            </category>
        </intent-filter>
    </receiver>
</application>

Broadcast Receiver

package awais.soft;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;

public class ServicesDemoActivity extends BroadcastReceiver {

static final int idBut = Menu.FIRST + 1, idIntentID = Menu.FIRST + 2;

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

    Log.e("Awais", "onReceive:");
    if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
        Intent i = new Intent();
        i.setAction("awais.kpsoft.MyService");
        context.startService(i);

    }

}

}

Service

package awais.soft;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service {
private static final String TAG = "MyService";
MediaPlayer player;

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onCreate() {
    Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onCreate");

    player = MediaPlayer.create(this, R.raw.is);
    player.setLooping(false); // Set looping
}

@Override
public void onDestroy() {
    Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onDestroy");
    player.stop();
}

@Override
public void onStart(Intent intent, int startid) {
    Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onStart");
    player.start();
}

}

  • 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-30T10:37:37+00:00Added an answer on May 30, 2026 at 10:37 am

    Everything was fine..:S
    The problem was with device..(i.e. Motorolla Zoom ICS 4.0.3)

    Now tested on Galaxy Tab With 2.2 and Working fine..

    Thanks all for your time

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

Sidebar

Related Questions

I'm currently trying to make a button which will take the user back to
I'm currently trying to make a page via php which allows the user to
I'm currently stuck on trying to make a naive algorithm which given a piece
I'm trying to start a status bar notification from a broadcast receiver and then
I am currently trying to make an existing VB.NET Project run. A null pointer
I am currently trying to make a game in Android. I have this piece
I'm currently trying to make a GreaseMonkey script that will allow a user to
I am Currently trying to make a shell script that will email me and
I am currently trying to make an Android App that communicates with Google App
I am currently trying to make a navigation-menu where an active-class is applied to

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.