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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:19:38+00:00 2026-06-09T22:19:38+00:00

I built an application that has an activity that i want to start from

  • 0

I built an application that has an activity that i want to start from the click of a status notification icon. What i want to happen is for my activity which i set to be shown as a dialog box to show up on top of whatever application is already open on the device.

But what happens now is that when the notification icon is clicked the dialog activity is launched along with the applications main activity underneath it, as seem in the image bellow.

http://postimage.org/image/s40v1588b/

How can i launch the dialog box so that it shows up over the current application on screen and my main activity isn’t launched?

Main Activity:

public class mainActivity extends Activity {
    public  NotificationManager mNotificationManager;
    private Button start;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        start = (Button) findViewById(R.id.start);
        start.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent myIntent = new Intent(getApplicationContext(), servicetest.class);
                startService(myIntent);
                Log.d("start","sms");
                Toast.makeText(SmseverywhereActivity.this, "Service Started",
                        Toast.LENGTH_LONG).show();
            }

        });

    }

}

Service that listens for notification press and starts dialog activity:

    public class servicetest extends Service{
        public  NotificationManager mNotificationManager;
        public Intent dialogIntent;

        @Override
        public IBinder onBind(Intent intent) {
            // TODO Auto-generated method stub
            return null;
        }
        @Override
        public void onCreate() {
            super.onCreate();
            Log.d("servicetest","onCreate");
            mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            showNotification();


            }


         private void showNotification(){
                Notification not = new Notification(R.drawable.ic_launcher, "Application started", System.currentTimeMillis());
                Intent myIntent = new Intent(this, dialogactivity.class);
                myIntent.putExtra("isFullScreen", true);
                myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                PendingIntent contentIntent = PendingIntent.getActivity(this, 0, myIntent, Notification.FLAG_ONGOING_EVENT);        
                not.flags = Notification.FLAG_ONGOING_EVENT;            
                not.setLatestEventInfo(this, "Application Name", "Application Description", contentIntent);
                mNotificationManager.notify(1, not);
            }



    }

Dialog activity:
public class dialogactivity extends Activity{
     @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.dialogtest);

     }
}

manifest:

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".SmseverywhereActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:label="@string/app_name"
            android:name="NewText"
            android:theme="@android:style/Theme.Dialog"
            android:launchMode="singleTask"
            android:screenOrientation="user">
        </activity>

        <service android:enabled="true" android:name=".servicetest" />
  • 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-06-09T22:19:40+00:00Added an answer on June 9, 2026 at 10:19 pm

    I figured out my problem, I needed to call finish(); from my main activity so that it wasn’t relaunched again every time my other activities were launched.

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

Sidebar

Related Questions

I have built a Java application that has some dependencies (~10). I would like
I have this consumer targeted application that has built in error reporting. Sometimes I
I'm developing an application on a hardware device that has a built-in hardware keyboard
I have an ASP.NET MVC3 application that I have built and it has two
We have an application that we have built as a bundle and we want
We have an SOA based project which has been built from the ground up
I have a pretty extensive application that has been built to provide SSO to
So I have built a small application that has a physics engine and a
We have a web application that has been built using MySQL / PHP /
I am working with a SharePoint application that has quite a bit of built

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.