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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:00:17+00:00 2026-05-28T05:00:17+00:00

I am doing an application in which I want to call a number when

  • 0

I am doing an application in which I want to call a number when that device boot completed. My code is like this:

 @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        System.out.println("**inside onRecevier");

        Intent serviceIntent = new Intent();
        serviceIntent.setAction("com.test.app.TestService");
        context.startService(serviceIntent); 

   }

First I created BroadcastReceiver. I registered this receiver in manifest file like this:

<receiver android:name="TestReceiver">
        <intent-filter>
             <action android:name="android.intent.action.BOOT_COMPLETED" />
             <category android:name="android.intent.category.HOME" />
        </intent-filter>    
    </receiver> 

In a receiver I called the below service:

public class TestService extends Service{

    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void onCreate() {
        // TODO Auto-generated method stub

        System.out.println("**inside onCreate");
        super.onCreate();
        Toast.makeText(this, "Service Created", Toast.LENGTH_LONG).show();
        Intent call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:+5555")); 
        startActivity(call);
    }

    @Override
    public void onDestroy() {
        // TODO Auto-generated method stub

        System.out.println("**inside onDestroy");
        super.onDestroy();
        Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        // TODO Auto-generated method stub
        System.out.println("**inside onStart");
        super.onStart(intent, startId);
        Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
    }

}

when I tried to boot a device after booting the application getting force close. How to do this in android??
Thanx 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-05-28T05:00:17+00:00Added an answer on May 28, 2026 at 5:00 am

    You need to add the NEW_TASK flag before starting an activity from a service:

    Intent call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:+5555"));
    call.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(call);
    

    This explains:

    Note that if this method is being called from outside of an Activity
    Context, then the Intent must include the FLAG_ACTIVITY_NEW_TASK
    launch flag. This is because, without being started from an existing
    Activity, there is no existing task in which to place the new activity
    and thus it needs to be placed in its own separate task.

    Also, you must hold the permissions:

    • RECEIVE_BOOT_COMPLETED
    • CALL_PHONE

    And as Waqas mentioned, it would be better for you to start your service from your onReceive like:

     Intent serviceIntent = new Intent(context, TestService.class);
     context.startService(serviceIntent); 
    

    Make sure you’ve done all that I’ve stated, and if you continue to have an issue, then it would be helpful if you edit your question and paste the logcat from the force close.

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

Sidebar

Related Questions

I want to make a automated call application, which will dial some mobile numbers,
im doing an application in which im transfering file through FTP.i succesfully done all
I am doing mail parsing application which required to convert the HTML file to
People always advised me that if I am doing some application that should use
I am doing a movieplayer application and I want to activate certain settings about
I want to display a progress bar while doing some work, but that would
We have a requirement in application that on clicking on all images which do
I have written an application that queries a web service I wrote (which returns
Essentially what I want to do is have a root application.haml that contains the
In a WCF client application, there are a number of parameterless methods for which

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.