Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent activity is opening over main activity. How to open it not over main activity?

I am building an application which will show a notification and on clicking the notification, I want to open a transparent dialog like activity which will have option related to that notification.

I defined a transparent activity and registered it in notification like this.

 Intent notificationIntent = new Intent(context, EasyToDoReminder.class);
 PendingIntent contentIntent = PendingIntent
                                .getActivity(context, 0, notificationIntent, 0);

The activity starts, but the main activity is statred behind it. How to open the Reminder activity independently?

And I am not trying to show a dialog. I want to show an activity look like a dialog. I am already using the theme as you mentioned. I have also one main activity. When I am trying to start my transparent dialog like activity, the main activity is getting started then over that the dialog like activity is started.

Anyone can please suggest to do this in a better approach?

like image 329
Arnab Avatar asked Aug 14 '12 02:08

Arnab


1 Answers

ok i had this problem too
use another LAUNCHER activity for second activity

manifest :

    <activity android:name=".popup.PopUp"
              android:label="~.Popup"
              android:theme="@style/Theme.Transparent"
              android:launchMode="singleInstance"
              android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and in intent :

        Intent i = new Intent();
        i.setClass(service.getBaseContext(), PopUp.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_SINGLE_TOP |
                Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        i.putExtra("id", id + "");
        context.startActivity(i);

if you call from a service use service.getBaseContext() , and if you not just use your context

like image 118
Hamidreza Sadegh Avatar answered Oct 19 '22 09:10

Hamidreza Sadegh