Sunday 15 August 2010

android - How to increase the speed to load an activity? -



android - How to increase the speed to load an activity? -

i developing android application , uses googlemaps. when click on button, load registraposizioneactivity shows google maps. have noted loading speed of activity slow. there mode increasing speed of loading activity?

this code:

protected void oncreate(bundle savedinstancestate) { try{ super.oncreate(savedinstancestate); setcontentview(r.layout.activity_recordposition); locationmanager = (locationmanager) getsystemservice(location_service); criteria criteria = new criteria(); criteria.setaccuracy(criteria.accuracy_fine); provider = locationmanager.getbestprovider(criteria, false); locationmanager.requestlocationupdates(provider, 1000, 0, this); settamappa(); if(myposition==null){ pdialog = progressdialog.show(this, "attendere ...", "localizzazione in corso ...", true); pdialog.setcancelable(false); } }catch(exception e){ log.e("errore oncreate:",e.getmessage()); utility.generatenoteonsd(filename,e.getmessage()); } } public void settamappa(){ mmap = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map2)).getmap(); mmap.setmaptype(googlemap.map_type_terrain); mmap.setmylocationenabled(true); }

this activity_recordposition.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:orientation="vertical" tools:context=".registraposizioneactivity" android:gravity="center"> <fragment android:name="com.google.android.gms.maps.supportmapfragment" android:id="@+id/map2" android:layout_height="0dp" android:layout_weight="10" android:layout_width="match_parent" class="com.google.android.gms.maps.supportmapfragment" /> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="horizontal" > <button android:id="@+id/buttonr" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.20" android:layout_margin="20dp" android:background="#0080c2" android:textcolor="#fff" android:textsize="20sp" android:onclick="registrapunto" android:text="@string/registrapunto" /> <button android:id="@+id/buttonsava" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.20" android:layout_margin="20dp" android:background="#0080c2" android:textcolor="#fff" android:textsize="20sp" android:onclick="savaareatracciata" android:text="@string/terminaregistrazione" /> </linearlayout>

to me seems you're doing lot of processing in oncreate method. seek moving of processing async thread. believe increment load times lot.

so,

load activity, within oncreate start async task async thread processing required after activity has loaded :)

android google-maps android-activity

No comments:

Post a Comment