2

I am having problems launching my application from my widget when it's clicked upon. Here is a cut of some code

// Create an Intent to launch activity
Intent intent = new Intent(context, Entry_MainTabView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);             
updateViews.setOnClickPendingIntent(R.id.Widget, pendingIntent);

Now take the scenario. I launch my app, exit to the home page , then click on my widget. It launches a second instance of the application, so when I hit "back" , the application goes away and reveals the other copy. I then hit back again and finally go back to the homescreen.

How can I make the Intent only create a new instance if none already exists in ram ?

Chris
  • 629
  • 3
  • 8
  • 14
  • There's not 2 applications running, there's 2 of the same activities running in your application. Declare your activity as singleinstance in your manifest. – Falmarri Dec 04 '10 at 23:26
  • ah - didn't notice that for the manifest , now works a treat. – Chris Dec 05 '10 at 07:29

1 Answers1

0

Have you looked at singleInstance and singleTask launch modes of an activity? This extract from Pro Android 2 indicates that there is no documented way of ensuring that there is only one instance of the widget running.

indyfromoz
  • 4,045
  • 26
  • 24