I am developing an app using phonegap and mobile jquery.
There’s a point in my app where it is running in the background and if an event triggered from js, I want to make my app to come in foreground.
How can I make my app come to foreground from background. I have a single activity with following attribute:
android:configChanges="orientation|keyboardHidden|screenLayout"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleTask"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
what i tried to make my app in foreground is :
Intent intent = new Intent(mContext , MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
mContext.startActivity(intent);
And
mContext.startActivity(((Activity)mContext).getIntent());
(MainActivity is the only activity in my app ) but it is not working. I am using android 4.0.
Update : In android 2.3 its working fine but its not working in android 4.0
After a effort I got a solution…
I implemented a broadcast listener. when i receive any event, i send a broadcast and in broadcast receiver i launch the app.
** Receiver** :