Note that there are some explanatory texts on larger screens.

plurals
  1. POlaunching mapview from main activity (button)
    text
    copied!<p>Going round in circles here i think.</p> <p>I have an activity called Locate;</p> <pre><code>public class Locate extends Activity { public static String lat; public static String lon; public static String number; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.locate); final Button buttonMaps = (Button) findViewById(R.id.ButtonMaps); buttonMaps.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); try { Intent i = new Intent(getBaseContext(), displayMap.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } catch (ActivityNotFoundException e) { Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_SHORT).show(); } }}); // Toast.makeText(getBaseContext(), "lat: " + lat + " long: " + lon + " from: " + testname, Toast.LENGTH_LONG).show(); } </code></pre> <p>If I make the displayMap class into a normal Activity, and just have display a toast message confirming it has loaded - then it works fine.</p> <p>If i do this though;</p> <pre><code>public class displayMap extends MapActivity { /** Called when the activity is first created. */ public void onCreate() { setContentView(R.layout.displaymap); Toast.makeText(getBaseContext(), "Display Map", Toast.LENGTH_SHORT).show(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } </code></pre> <p>Then as soon as I click the Button, I get a force close.</p> <p>I have the correct 'uses-library' tag in my manifest;</p> <pre><code>&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;uses-library android:name="com.google.android.maps" /&gt; </code></pre> <p>I don't get what it just force closes everytime i try and load it.</p> <p>If I make this my onClick handler then it will fire up a working googlemaps/default mapview</p> <pre><code> public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); Uri uri=Uri.parse("geo:"+Locate.lat+","+Locate.lon); StartActivity(new Intent(Intent.ACTION_VIEW, uri)); } </code></pre> <p>But that is not what I am trying to do, I want my own - so that I can add overlays etc to it. But it does prove that the permission are set correctly and that the lib is there.</p> <p>The logcat error when the app FCs is a Unexpected DEX error.</p> <p>Can anyone point in the right direction here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload