1

I am using Broadcast receiver to start my activity..

Broadcast Receiver Called Using Alarm Manager:

AlarmManager mAlarmManager = 
    (AlarmManager) getSystemService(Context.ALARM_SERVICE);

Intent mIntent = 
    new Intent(this, BrodcastRec.class);

PendingIntent mPendingIntent = 
    PendingIntent.getBroadcast(
        this, 
        0, 
        mIntent, 
        PendingIntent.FLAG_CANCEL_CURRENT);

mAlarmManager.set(AlarmManager.RTC_WAKEUP, miliSecounds, mPendingIntent);

In my Broadcast Receiver

@Override
    public void onReceive(Context context, Intent intent) {
        Intent intentObject = new Intent(context.getApplicationContext(), ActicityWhichIWantToKill.class);
        intentObject.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        context.startActivity(intentObject);
} 

In The ActivityWhichIWantToKill

i will create the function to finishOrKill

closeApplication()
{
  finishAffinity();
}

Solution Which I have Tried

1.Adding In Manifest.XML

<Application>
...

<activity android:name=".activity.ActicityWhichIWantToKill"
            android:excludeFromRecents="true"
            android:noHistory="true"></activity>
....
</Application>
  1. Adding Flags In Intent Object

    intentObject.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    
  2. Use Intent

        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory( Intent.CATEGORY_HOME );
        homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(homeIntent);
    

My question is how to remove application from recent task ?

I am researching since 3 hours All solution Tried But No Achieved Any Result Can some one Help me to solve this ?

Thanks In Advance......

Florescu Cătălin
  • 4,320
  • 1
  • 20
  • 32
Ashvin solanki
  • 3,679
  • 1
  • 17
  • 49

0 Answers0