1

I have an application in which I want to show a custom activity(Access Denied) when user try to share an image.

When I am trying to share an image from default 'Downloads' application (For eg: share image through default message/gmail application) the custom activity is showed and exits 'Downloads' application.But next time when I launch the 'Downloads' application and press on an image the previously created draft mail/message is shown as the top activity.So it shows the custom activity always.

Launched the 'Downloads' application by using this intent.

Intent intent = new Intent(Intent.ACTION_MAIN); 
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(packagename,className));
startActivity(intent);

How can I fix this? I want to launch the 'Downloads' application as new (removing history of gmail/message etc.) every time.

Mogsdad
  • 42,835
  • 20
  • 145
  • 262
Devu Soman
  • 2,208
  • 13
  • 34
  • 56

1 Answers1

0

Please try below code

Intent intent = new Intent(ClassA.this, ClassB.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intent);
saravanan
  • 390
  • 2
  • 16