android - How can I start a new activity when I click on infoWindowAdapter? -



android - How can I start a new activity when I click on infoWindowAdapter? -

hi guys i'm beginner android, wanna start new activity when force on infowindowadapter in map. code seems easy doesn't work, don't know why. can help me? have declared new activity (moreinfoactivity) in manifest , wanna phone call main activity. below can find "moreinfoactivity" source, phone call mainactivity , declaration within manifest. give thanks much

call mainactivity when force on infowindowadapter: [updated]

final activity thiz = this; map.setoninfowindowclicklistener(new oninfowindowclicklistener() { @override public void oninfowindowclick(marker marker) { /*nuova chiamata di united nations activity (scelta perché più pratica e la richiamiamo anche dalla listview)*/ /*************************************************************************************************/ string nome_luogo = marker.gettitle(); intent piu_info = new intent(thiz, moreinfoactivity.class); piu_info.putextra("nome", nome_luogo); startactivity(piu_info); /*************************************************************************************************/ } });

moreinfoactivity: [updated]

public class moreinfoactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_moreinfo); bundle extras = getintent().getextras(); if (extras != null){ string value = extras.getstring("nome"); prendi_informazioni(value); } } public void prendi_informazioni(string nome_luogo){ view layout = getwindow().getdecorview().findviewbyid(r.id.immagine_luogo); //string nome_luogo = marker.gettitle(); buildinfomatrix printinfo = new buildinfomatrix(); printinfo.fill_matrix(); printinfo.read_matrix(nome_luogo, layout); } }

manifest:

<!-- more informations activity --> <activity android:name="com.example.findmyclients.moreinfoactivity" android:screenorientation="portrait"> </activity>

logcat: http://pastebin.com/pkuw4lck

i'm not exclusively sure syntax correct. part i'm questioning mainactivity.this. i'm not exclusively sure means may instance of class. instead, create activity variable outside of clicklistener , reference clicklistener. example:

final activity thiz = this; /* needs final can reference in inner class */ map.setoninfowindowclicklistener(new oninfowindowclicklistener() { @override public void oninfowindowclick(marker marker) { view v2 = getlayoutinflater().inflate(r.layout.activity_moreinfo, null); moreinfoactivity prova = new moreinfoactivity(); prova.prendi_informazioni(marker); intent piu_info = new intent(thiz, moreinfoactivity.class); startactivity(piu_info); }

});

as side note, should never instantiating instances of activities yourself. if need pass arguments activity, attach intent adding extras. see here: http://developer.android.com/reference/android/content/intent.html#putextra(java.lang.string, double[])

for example:

string nome_luogo = marker.gettitle(); piu_info.putextra("marker", nome_luogo );

and in oncreate of moreinfoactivity:

string marker = getintent().getextras().getstring("marker"); dosomething(marker);

the way you're doing now, if don't null pointer exception, argument won't seen moreinfoactivity

android android-activity

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -