Reputation: 8670
I am trying to add upload image feature in my application, using android-upload-service.
I am facing a issue not specific to the library.
When i am clicking on upload notification I want to open a activity using Intent.
code:
val intent = Intent(context, EditorActivity::class.java)
intent.putExtra("ResourceId", resourceId)//No I18N
context.startActivity(intent)
But,
How can i check is the specific activity is dead or running and on Screen. current code is starting the activity on top of present activity because of what i am having same activity on top of each other.
Upvotes: 1
Views: 175
Reputation: 262
First, add android:launchMode="singleTask" for that activity in your AndroidManifest.xml file. This will make sure that there is only one instance of the activity at all time.
Example,
<activity
android:name=".activities.MyActivity"
android:launchMode="singleTask"/>
Upvotes: 1
Reputation: 95578
Add launchMode="singleTop"
to the <activity>
definition in the manifest. That should be enough to do what you want. It tells Android that it should use an existing instance of the Activity
instead of creating a new one, if an instance of that Activity
already exists at the top of the activity stack in the task.
Please don't use one of the special launch modes singleTask
or singleInstance
as these usually create more problems than they solve if you do not know exactly what you are doing.
Upvotes: 1