Reputation: 23
To help new students at Idaho State University find buildings, classrooms, etc we have created a web map that runs very nicely on Android or iOS.
The web map has an extremely long URL so we made a bit.ly link to it as well as a QR-code. The web map can be viewed at http://bit.ly/isumap
I am getting requests now to create an app (starting with Android) that can be downloaded and installed by students (as well as faculty, staff, and visitors). The app will do nothing more than launch the web map for them on their mobile device. Hence they do not need to remember a URL or do any typing.
I have installed the Android SDK (with Eclipse) and I am sure it is working just fine. I have used stackOverflow to help me so far but am now stuck. While the app sort of runs, I get this error "Unfortunately, gISU has stopped". But it really has not stopped... the URL is launched correctly. How can I fix this so I do not get this error? In other words how do I get Android to handle this event successfully.
The code is very simple: MainActivity.Java package com.example.gisumap;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
//import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
String url = "http://isu.maps.arcgis.com/apps/Solutions/s2.html? appid=8f29d302702249069af69eb5da6f1299&ex=-12517238,5290414,-12514181,5292459,102100";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
finish();
moveTaskToBack(true);
}
}
And here is the manifest
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.gisumap.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have edited the manifest to include a for INTERNET.
Here also is the LogCat 03-14 13:56:14.470: D/AndroidRuntime(986): Shutting down VM 03-14 13:56:14.470: W/dalvikvm(986): threadid=1: thread exiting with uncaught exception (group=0xb3ac3b90) 03-14 13:56:14.480: E/AndroidRuntime(986): FATAL EXCEPTION: main 03-14 13:56:14.480: E/AndroidRuntime(986): Process: com.example.gisumap, PID: 986 03-14 13:56:14.480: E/AndroidRuntime(986): android.util.SuperNotCalledException: Activity {com.example.gisumap/com.example.gisumap.MainActivity} did not call through to super.onCreate() 03-14 13:56:14.480: E/AndroidRuntime(986): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2142) 03-14 13:56:14.480: E/AndroidRuntime(986): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226) 03-14 13:56:14.480: E/AndroidRuntime(986): at android.app.ActivityThread.access$700(ActivityThread.java:135) 03-14 13:56:14.480: E/AndroidRuntime(986): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397) 03-14 13:56:14.480: E/AndroidRuntime(986): at android.os.Handler.dispatchMessage(Handler.java:102) 03-14 13:56:14.480: E/AndroidRuntime(986): at android.os.Looper.loop(Looper.java:137) 03-14 13:56:14.480: E/AndroidRuntime(986): at android.app.ActivityThread.main(ActivityThread.java:4998) 03-14 13:56:14.480: E/AndroidRuntime(986): at java.lang.reflect.Method.invokeNative(Native Method) 03-14 13:56:14.480: E/AndroidRuntime(986): at java.lang.reflect.Method.invoke(Method.java:515) 03-14 13:56:14.480: E/AndroidRuntime(986): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 03-14 13:56:14.480: E/AndroidRuntime(986): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 03-14 13:56:14.480: E/AndroidRuntime(986): at dalvik.system.NativeStart.main(Native Method) 03-14 13:56:45.087: I/Process(986): Sending signal. PID: 986 SIG: 9
Thank you all.
Wow! Great job and a great group. For others reading this later, to make this work I followed the advice of the knowledgeable posters.
Using the code i first posted:
removed the line "moveTaskToBack(true);" from MainActivity added a line in the manifest: And finally, (the clincher) added a line in MainActivity for the super:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
It works now! Thanks a million.
Upvotes: 2
Views: 584
Reputation: 11323
You forgot to call super.onCreate! Add this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //add this line
see documentation
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
==> that is what your logcat complains about here:
android.util.SuperNotCalledException: Activity {com.example.gisumap/com.example.gisumap.MainActivity}
did not call through to super.onCreate()
Upvotes: 1
Reputation: 5626
You need to add an Internet Permission in your AndroidManifest file for this to work and I would also suggest using a webview to load the URL at some point!
Upvotes: 0