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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:55:38+00:00 2026-05-14T04:55:38+00:00

I want to know if it is possible to call an activity through background

  • 0

I want to know if it is possible to call an activity through background service in android like :

import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;



public class background extends Service{

 private int timer1;
 @Override
 public void onCreate() {
  // TODO Auto-generated method stub
  super.onCreate();

  SharedPreferences preferences = getSharedPreferences("SaveTime", MODE_PRIVATE);
  timer1 = preferences.getInt("time", 0);
  startservice();
 }

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

 private void startservice() {

  Handler handler = new Handler();
  handler.postDelayed(new Runnable(){
   public void run() {
    mediaPlayerPlay.sendEmptyMessage(0);
   }
  }, timer1*60*1000);
 }

 private Handler mediaPlayerPlay = new Handler(){

  @Override
  public void handleMessage(Message msg) {
   try
   {
    getApplication();
    MediaPlayer mp = new MediaPlayer();

    mp = MediaPlayer.create(background.this, R.raw.alarm);
    mp.start();

   }
   catch(Exception e)
   {
    e.printStackTrace();
   }
   super.handleMessage(msg);
  }
 };


 /*
  * (non-Javadoc)
  * 
  * @see android.app.Service#onDestroy()
  */
 @Override
 public void onDestroy() {
  // TODO Auto-generated method stub

  super.onDestroy();
 }
}

i want to call my activity……

  • 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-14T04:55:38+00:00Added an answer on May 14, 2026 at 4:55 am

    You can call an Activity while onStart() of your service…..

    Snippet might be as follows:

    @Override 
    public void onStart(Intent intent, int startId)  { 
    ...
    Log.i("Service", "onStart() is called"); 
    Intent callIntent = new Intent(Intent.ACTION_CALL); 
    callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    callIntent.setClass(<Set your package name and class name here>);
    startActivity(callIntent);
    ...
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have preperd a remote service, i would like to know if it's possible
I wanna know if it's possible to call php api like in extjs 3.x.x.
I can call a webservice with KSOAP2 from android,now i want to know is
I want to know is it possible to call a php function within javascript,
I want to know whether it is possible to create an Android application to
i want to know if it is possible to call JSF events, such as
I want to know if it is possible to call the T4 custom tool
I want to know whether a single button in Android can call a web
I would like to know if its possible to call a non-const member function
i want know if is possible, to get a specific element value of a

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.