views:

35

answers:

0

I have an application that has one service and 2 activities.One activity (the main one) is a preferences activity and the other one is a dialog themed activity. The service from time to time needs to open only the dialog themed activity (using FLAG_ACTIVITY_NEW_TASK). The problem is that when the preferences activity is opened in background (for example the user pressed HOME key instead of BACK, so the activity is OnPause) and the service tries to open the dialog themed activity, also the main activity is opened (comes in foreground). I don't want this. So, how can I open only the themed activity from the service, without the main activity pop up ?

Android Manifest .xml

    <service android:name=".SimpleService"> </service>
<activity
    android:name=".Preferences" 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:name=".popup_activity" android:theme="@android:style/Theme.Dialog" android:label="@string/app_name">                  
           <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.SAMPLE_CODE" />
           </intent-filter>
           <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="screenon.popup.activity" />
                    <category android:name="android.intent.category.DEFAULT" />
           </intent-filter>           
            </activity>

And from the service :

           Intent intent = new Intent(Intent.ACTION_VIEW);
               intent.addCategory("screenon.popup.activity");
               intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

               startActivity(intent);