import java.util.Locale;\r
\r
import android.app.Activity;\r
+import android.app.AlertDialog;\r
import android.content.Context;\r
import android.content.Intent;\r
import android.content.res.Resources;\r
+import android.content.DialogInterface;\r
import android.media.AudioManager;\r
import android.os.Bundle;\r
import android.os.Handler;\r
import android.os.PowerManager;\r
import android.util.DisplayMetrics;\r
import android.util.Log;\r
+import android.net.Uri;\r
import android.view.Display;\r
import android.view.Menu;\r
import android.view.MenuItem;\r
private static Intent startup_intent = null;\r
private static long startup_intent_timestamp = 0L;\r
public static String my_display_density = "mdpi";\r
+ private boolean parseErrorShown = false;\r
\r
private boolean extractRes(String resname, String result)\r
{\r
String temp1 = null;\r
String temp2 = null;\r
String temp3 = null;\r
+ boolean parsable = true;\r
\r
// if b: then remodel the input string to look like a:\r
if (intent_data.substring(0, 20).equals("google.navigation:q="))\r
{\r
intent_data = intent_data + "&q=Target";\r
}\r
-\r
-\r
- // now string should be in form --> a:\r
- // now split the parts off\r
- temp1 = intent_data.split("&q=", -1)[0];\r
- try\r
- {\r
- temp3 = temp1.split("ll=", -1)[1];\r
- temp2 = intent_data.split("&q=", -1)[1];\r
- }\r
- catch (Exception e)\r
+ else\r
{\r
- // java.lang.ArrayIndexOutOfBoundsException most likely\r
- // so let's assume we dont have '&q=xxxx'\r
- temp3 = temp1;\r
+ \r
+ // string not parsable, display alert and continue w/o string\r
+ AlertDialog.Builder alertbox = new AlertDialog.Builder(this);\r
+ alertbox.setMessage("Navit recieved the query "+intent_data+"\nThis is not yet parsable.");\r
+ alertbox.setPositiveButton("Ok", new DialogInterface.OnClickListener(){\r
+ public void onClick(DialogInterface arg0, int arg1) {\r
+ Log.e("Navit","Accepted non-parsable string");\r
+ }\r
+ });\r
+ alertbox.setNeutralButton("More info", new DialogInterface.OnClickListener(){\r
+ public void onClick(DialogInterface arg0, int arg1) { \r
+ String url = "http://wiki.navit-project.org/index.php/Navit_on_Android#Parse_error";\r
+ Intent i = new Intent(Intent.ACTION_VIEW);\r
+ i.setData(Uri.parse(url));\r
+ startActivity(i);\r
+ }\r
+ });\r
+ if (!parseErrorShown)\r
+ {\r
+ alertbox.show();\r
+ parseErrorShown = true;\r
+ }\r
+ parsable = false;\r
}\r
\r
- if (temp2 == null)\r
+ if (parsable)\r
{\r
- // use some default name\r
- temp2 = "Target";\r
- }\r
+ // now string should be in form --> a:\r
+ // now split the parts off\r
+ temp1 = intent_data.split("&q=", -1)[0];\r
+ try\r
+ {\r
+ temp3 = temp1.split("ll=", -1)[1];\r
+ temp2 = intent_data.split("&q=", -1)[1];\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ // java.lang.ArrayIndexOutOfBoundsException most likely\r
+ // so let's assume we dont have '&q=xxxx'\r
+ temp3 = temp1;\r
+ }\r
\r
- lat = temp3.split(",", -1)[0];\r
- lon = temp3.split(",", -1)[1];\r
- q = temp2;\r
-\r
- Message msg = new Message();\r
- Bundle b = new Bundle();\r
- b.putInt("Callback", 3);\r
- b.putString("lat", lat);\r
- b.putString("lon", lon);\r
- b.putString("q", q);\r
- msg.setData(b);\r
- N_NavitGraphics.callback_handler.sendMessage(msg);\r
- }\r
+ if (temp2 == null)\r
+ {\r
+ // use some default name\r
+ temp2 = "Target";\r
+ } \r
+\r
+ lat = temp3.split(",", -1)[0]; \r
+ lon = temp3.split(",", -1)[1];\r
+ q = temp2;\r
\r
+ Message msg = new Message();\r
+ Bundle b = new Bundle();\r
+ b.putInt("Callback", 3);\r
+ b.putString("lat", lat);\r
+ b.putString("lon", lon);\r
+ b.putString("q", q);\r
+ msg.setData(b);\r
+ N_NavitGraphics.callback_handler.sendMessage(msg);\r
+ }\r
+ }\r
}\r
@Override\r
public void onPause()\r