I am creating a cross platform app in Adobe Flex with AIR 3.3 SDK. For Android, I have created a native extension which launches a native android activity with a simple view in it by firing an Intent.
The issue is that when we minimize the app and resume it by either choosing the app icon from apps menu or by long pressing home button to get list of recent apps, Android automatically calls the onDestroy of the native android activity and kills it. The same scenario works perfectly fine on Android 4.0. The problem is happening only on Android 2.x devices. We haven't been able to test honeycomb yet.
After reading the Android documents, I understand that onDestroy is either called when someone calls finish on the activity or if the device is running low on space. And, to distinguish between the both, one can use the isFinishing() method. This would return true if activity has been destroyed by calling finish.
In our case, in the scenario described above, activity's finish function is not called. onDestroy is called when the app resumes but isFinishing() still returns true. This suggests that the app is not low on memory. I have tried adding all kind of Flags to the intent but nothing changes the behavior.
I have no idea from where else can the onDestroy function be called? I need to figure out a way to stop the native activity from being destroyed on app resume.
The code to launch the native activity is something like this:
Intent intent = new Intent("android.intent.action.K12");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("params", parameters);
context.getActivity().startActivity(intent);
The entry for the activity in the manifest goes like this:
<activity android:name="com.k12.main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.K12" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I have read a lot of blogs and SO questions but could not get around this issue. Please help.