Android geliştiricisinin blogunda Tim Bray's post "New Gingerbread API: StrictMode" okuduktan sonra, projemde kullanmaya karar verdim. Performans sorunlarının, sorun olmadan önce yakalanmasına yardımcı olmayı umuyorum.MapActivity with StrictMode çalışmıyor - Yardım
Sorunum, MapActivity özelliğini her yüklediğimde, uygulamanın kaldığı, ancak yalnızca StrictMode etkin olduğunda karşılaştığım. Basit, kod aktivitesi olmadan bile ölür.
Herkes, StrictMode'u MapActivity ile başarıyla kullandı mı? Eğer öyleyse, hile nedir?
LogCat çıktısı şu şekildedir:
TestActivity - onCreate
TestActivity - onStart
TestActivity - onResume
Handling network change notification:CONNECTED
Couldn't get connection factory client
StrictMode policy violation; ~duration=344 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=343 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:745)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:330)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:280)
at com.google.android.gsf.settings.GoogleSettingsProvider.query(GoogleSettingsProvider.java:142)
at android.content.ContentProvider$Transport.bulkQuery(ContentProvider.java:174)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:111)
at android.os.Binder.execTransact(Binder.java:320)
at dalvik.system.NativeStart.run(Native Method)
# via Binder call with stack:
android.os.StrictMode$LogStackTrace
at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1059)
at android.os.Parcel.readExceptionCode(Parcel.java:1304)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:111)
at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:262)
at android_maps_conflict_avoidance.com.google.common.android.AndroidConfig.getSetting(AndroidConfig.java:216)
at android_maps_conflict_avoidance.com.google.common.android.AndroidConfig.getDistributionChannelInternal(AndroidConfig.java:195)
at android_maps_conflict_avoidance.com.google.common.Config.init(Config.java:273)
at android_maps_conflict_avoidance.com.google.common.android.AndroidConfig.<init>(AndroidConfig.java:100)
at android_maps_conflict_avoidance.com.google.common.android.AndroidConfig.<init>(AndroidConfig.java:87)
at com.google.android.maps.MapActivity.onCreate(MapActivity.java:419)
at com.company.project.UI.TestActivity.onCreate(TestActivity.java:15)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
at android.widget.TabHost.setCurrentTab(TabHost.java:326)
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
StrictMode policy violation with POLICY_DEATH; shutting down.
Sending signal. PID: 1254 SIG: 9
Process com.company.project (pid 1254) has died.
channel '4073e288 com.company.project/com.company.project.UI.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
channel '4073e288 com.company.project/com.company.project.UI.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
WIN DEATH: Window{4073e288 com.company.project/com.company.project.UI.MainActivity paused=false}
Etkinlik kod şudur: (Ben ekstra şeyler var biliyorum ama standart yöntemler yürütme yaptıklarını görmek istedim)
public class TestActivity extends MapActivity {
private final static String TAG = "TestActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Log.d(TAG, "TestActivity - onCreate");
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Log.d(TAG, "TestActivity - onStart");
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.d(TAG, "TestActivity - onResume");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Log.d(TAG, "TestActivity - onPause");
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
Log.d(TAG, "TestActivity - onStop");
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
Log.d(TAG, "TestActivity - onRestart");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.d(TAG, "TestActivity - onDestroy");
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
Log.d(TAG, "TestActivity - isRouteDisplayed");
return false;
}
}
düzen :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.maps.MapView
android:id="@+id/campusMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="<key>" />
</LinearLayout>
.: Belki de ana uygulama iş parçacığı üzerinde G/Ç ile karşılaştığında ne yaptığı açısından çok StresifMode 'StrictMode ayarlanmış gibi görünüyor. "StrictMode" yapılandırma kodunuzu gösterebilir misiniz? – CommonsWare
Orijinal kodum: StrictMode.setThreadPolicy (new StrictMode.ThreadPolicy.Builder(). DetectAll(). PenaltyLog(). PenaltyDeath(). Build()); StrictMode.setVmPolicy (yeni StrictMode.VmPolicy.Builder(). DetectAll(). PenaltyLog(). PenaltyDeath(). Build()); ancak bunu değiştirdim: StrictMode.setThreadPolicy (yeni StrictMode.ThreadPolicy.Builder(). DetectAll(). PenaltyLog(). Build()); StrictMode.setVmPolicy (yeni StrictMode.VmPolicy.Builder(). DetectAll(). PenaltyLog(). Build()); remove .penaltyDeath() –
Ve bunu düzeltdi mi? penaltyDeath(), iyi, final. :-) – CommonsWare