Question: I want to start my `MainActivity` with a new `Intent` in my other `Activity`. The two Activities are in the same app, and the second Activity is actually started from the MainActivity. So the scenario is like this:

1. MainActivity is created with an Intent
2. MainActivity starts SecondActivity (but MainActivity is not destroyed yet. It is just stopped)
3. SecondActivity starts MainActivity with a new Intent (SecondActivity is not closed)

The MainActivity is not flagged. I mean, the Activity's launch mode in the manifest is not set (so, it's default).

I want to know what happens to MainActivity's lifecycle and intent.

Is the Activity re-created? Is `onCreate()` called? Then is `onCreate()` called twice, without `onDestory()`? Or the new MainActivity is newly created and there will be two MainActivities? Will the Intent from `getIntent()` overwritten?

I know `Activity.onNewIntent()` is called for singleTop Activities. Then in my situation `onNewIntent()` is not called?

Thanks in advance.

Answer: 
Create a table with single autoincrement column.

When you need another unique id - just insert `null` into that column and retrieve last insert id.

For oracle - create a sequence and use `SELECT sequence_name.nextval` FROM DUAL`

For sql server - create a sequence and fetch it with `NEXT VALUE FOR`
In SQL Server to generate truly unique ID I suggest using GUID, e.g.:

```
DECLARE @UniqueID uniqueidentifier
SET @UniqueID = NEWID()

```