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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:32:41+00:00 2026-05-31T22:32:41+00:00

I want to start an activity when the service is ran for the first

  • 0

I want to start an activity when the service is ran for the first time displaying a layout.

I have the following xml file :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.display.helper"
      android:versionCode="1"
      android:versionName="0.1.124">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"></uses-permission>
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.TELEPHONY"/>
    <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
      <activity android:name=".GpsTrackActivity" android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

      </intent-filter>
    </activity> 
       <service android:name=".dhaService" >
       <intent-filter>
       <action
       android:name = "com.display.helper.dhaService">
       </action>
       </intent-filter>
       </service>
       <receiver android:name=".dha">
       <intent-filter>
       <action
       android:name ="android.intent.action.BOOT_COMPLETED">
...

And i do this in the StartService method:

public class dhaService extends Service 
 {
    @Override
    public ComponentName startService(Intent service) {
        // TODO Auto-generated method stub
        Notification note = new Notification(R.drawable.icon,"sadasd",System.currentTimeMillis());
        note.setLatestEventInfo(this, "Tracking device", "Tracking", null);
        note.flags |= Notification.FLAG_NO_CLEAR;
        this.startForeground(1212,note);
        Intent dialogIntent = new Intent(getBaseContext(),GpsTrackActivity.class);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getApplication().startActivity(dialogIntent);
        return super.startService(service);

    }

The layout is never displayed what am i doing wrong ?

  • 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-31T22:32:42+00:00Added an answer on May 31, 2026 at 10:32 pm

    The documentation says: “A dialog is always created and displayed as a part of an Activity.” I’m thinking you need to activate an Activity (possibly one with no regular screen) and override the onCreateDialog(int) callback.

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

Sidebar

Related Questions

I have a phonegap activity which I want to start via a button press:
I have the following question: I start my activity and i call bindService in
I want to start a service once my activity is put in the background
I have service with thread, From activity I am calling start service(from Activity::onDestroy()) and
I have an activity thats already binded to the service. When I start the
my usecase is (roughly) the following on first startup: activity starts a service service
In my app, I have an Activity from which I want to start a
I have an activity and I want it to be updated from a service.
I want to start multiple instance of the same Activity class from a Service
Hello have to start a new Activity from the BroascastReceiver or the Service, but

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.