Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle maps fails to open in second activity
    primarykey
    data
    text
    <p>I'm making an application and ran into a problem.<br> I made separately app for google maps and it worked perfect, and I made second app in which I have listview, and by clicking on item in listview, another activity starts where google maps with different marks opens.<br> So I manage to get another activity running after clicking on separate objects in listview, so I modified that objects .xml and .java file on same principle as I did in my google maps app but somehow it doesn't works. </p> <p><strong>Main_Activity</strong></p> <pre><code> package com.example.e_idem; import android.os.Bundle; import android.app.AlertDialog; import android.app.ListActivity; import android.content.DialogInterface; import android.content.Intent; import android.view.Gravity; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends ListActivity { String [] usluga = { "Frizerski salon", "Kafić", "Vodoinstalater", "Bravar", "Ljekarna", "Pekara", "Autoservis", "Dućan", "Knjižnica", "Papirnica", "Željezara", "Smartshop", "Servis bicikla" }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Odaberite uslugu koju tražite.") .setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); AlertDialog alert = builder.create(); alert.show(); TextView messageView = (TextView)alert.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, usluga)); } public void onListItemClick(ListView parent, View view, int position,long id) { Toast.makeText(this, "Odabrali ste uslugu : "+usluga[position], Toast.LENGTH_LONG).show(); switch( position ) { case 0: Intent activity_frizerski_salon = new Intent(this, FrizerskiSalon.class); startActivity(activity_frizerski_salon); break; case 1: Intent activity_kafic = new Intent(this, Kafic.class); startActivity(activity_kafic); break; case 2: Intent activity_vodoinstalater= new Intent(this, Vodoinstalater.class); startActivity(activity_vodoinstalater); break; } } } </code></pre> <p><strong>Activity I call in Main_Activity for clicking an object in listview</strong></p> <pre><code> package com.example.e_idem; import com.google.android.gms.maps.*; import com.google.android.gms.maps.model.*; import android.app.Activity; import android.app.ListActivity; import android.os.Bundle; public class FrizerskiSalon extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_frizerski_salon); // Get a handle to the Map Fragment GoogleMap map = ((MapFragment) getFragmentManager() .findFragmentById(R.id.fmap)).getMap(); LatLng vz = new LatLng(46.305746, 16.336606); map.setMyLocationEnabled(true); map.moveCamera(CameraUpdateFactory.newLatLngZoom(vz, 13)); map.addMarker(new MarkerOptions() .title("Varaždin") .snippet("Barokni grad") .position(vz)); map.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.flag_red)) .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left .position(new LatLng(46.300274, 16.330769))); map.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.flag_red)) .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left .position(new LatLng(46.306274, 16.300769))); map.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.flag_red)) .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left .position(new LatLng(46.306974, 16.303169))); map.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.flag_red)) .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left .position(new LatLng(46.302874, 16.400710))); } } </code></pre> <p><strong>Manifest</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.e_idem" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" /&gt; &lt;permission android:name="com.example.e_idem.permission.MAPS_RECEIVE" android:protectionLevel="signature" /&gt; &lt;uses-permission android:name="com.example.e_idem.permission.MAPS_RECEIVE" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-feature android:glEsVersion="0x00020000" android:required="true" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/house_flag" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.e_idem.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.example.e_idem.FrizerskiSalon" android:label="@string/activity_frizerski_salon" &gt; &lt;/activity&gt; &lt;activity android:name="com.example.e_idem.Kafic" android:label="@string/activity_kafic" &gt; &lt;/activity&gt; &lt;activity android:name="com.example.e_idem.Vodoinstalater" android:label="@string/activity_vodoinstalater" &gt; &lt;/activity&gt; &lt;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCKxxxxxxxxxxxxxxxxxxVfSY_9zxmU"/&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>And my LogCat <a href="http://paste.strictfp.com/39582" rel="nofollow">http://paste.strictfp.com/39582</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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