How to start an Android activity when a PhoneGap app launches?

android, android-activity, cordova, webview

Solution

Unfortunately it looks like it can't be done;

http://community.phonegap.com/nitobi/topics/how_to_start_an_android_activity_when_a_phonegap_app_launches

Problem

I have created a MainActivity that extends Activity (also tried extending CordovaActivity), and would like to show this activity immediately when the PhoneGap app is launched. The problem is that no matter what I try to adjust in various configs etc, the manifest file is partially overwritten and a webview that loads www\index.html is shown. I probably don't need much of the original PhoneGap functionality for this app, but I would like to use build.phonegap.com to build and deploy it. Rewriting the Cordova webview class to make it start my activity in a new intent could be a solution I guess, but there's got to be another (config) way around this? AndroidManifest.xml (before build.phonegap.com): ``` <?xml version='1.0' encoding='utf-8'?> <manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="com.mystuff.myapp" xmlns:android="http://schemas.android.com/apk/res/android"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="com.mystuff.myapp.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /> </manifest> ``` AndroidManifest.xml (after build.phonegap.com, on the phone with ManifestViewer): ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="42" android:versionName="1.0.0" android:windowSoftInputMode="stateUnspecified|adjustPan" android:installLocation="auto" package="com.mystuff.myapp"> <supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:resizeable="true" android:xlargeScreens="true"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:label="@2130968576" android:icon="@2130837504" android:debuggable="true" android:hardwareAccelerated="true"> <activity android:label="@2130968576" android:name=".MyApp" android:screenOrientation="unspecified" android:configChanges="locale|keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="stateUnspecified|adjustUnspecified"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:label="@2130968576" android:name="com.phonegap.DroidGap"> <intent-filter/> </activity> </application> <uses-sdk android:minSdkVersion="7"/> </manifest> ```

Original source