2017-06-24 10 views
0

私は単純なosmdroidを作成し、それに続いてgitを構成しました。デバイスにosmdroidマップが表示されない

これが私のマニフェストです:

<?xml version="1.0" encoding="utf-8"?> 

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 
</manifest> 

build.gradle:

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 25 
buildToolsVersion "25.0.3" 
defaultConfig { 
    applicationId "com.example.sayres.myosm" 
    minSdkVersion 15 
    targetSdkVersion 25 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
testCompile 'junit:junit:4.12' 
compile 'org.osmdroid:osmdroid-android:5.6.4' 
compile 'com.github.MKergall:osmbonuspack:6.3' 

} 

私の活動:

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    Context ctx = getApplicationContext(); 
    //important! set your user agent to prevent getting banned from the osm servers 
    Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx)); 
    setContentView(R.layout.activity_main); 


    osm = (MapView) findViewById(R.id.mapView); 
    osm.setTileSource(TileSourceFactory.MAPNIK); 
    osm.setBuiltInZoomControls(true); 
    osm.setMultiTouchControls(true); 

    mc = (MapController) osm.getController(); 
    mc.setZoom(12); 

    GeoPoint center = new GeoPoint(36.680725,48.500430); 
    mc.animateTo(center); 



} 

@Override 
protected void onResume() { 
    super.onResume(); 
    //this will refresh the osmdroid configuration on resuming. 
    //if you make changes to the configuration, use 
    //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 
    //Configuration.getInstance().save(this, prefs); 
    Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this)); 
} 

しかし、私は私のアプリを実行すると、何もデバイスに表示されません!私はそのギターに言及したことすべてを行うが、私はどこに問題があるのか​​分からない。私のプロジェクトはインストールされて実行されますが、デバイスに何も表示されません。私はテストのためにAVDを使用しています。 私はこれを読んでいますpostしかしそれは何の意味ですか?

答えて

0

MapViewが表示されない、またはマップタイルが表示されていないことを意味しますか?

osmdroidを使用しているアプリケーションでは、ユーザーが権限を受け入れる前にMapViewの初期化に問題があったため、MainActivity(基本的にユーザーがアクセス許可を受け入れることができるように)の開始ページを作成し、MapViewを別のアクティビティ。あなたが見たい場合は、ソースコードはhttps://github.com/frodegill/GridWalking

で入手できます。最近のosmdroidバージョンでは、ファイルシステムではなくsqliteにタイルを格納するので、WRITE_EXTERNAL_STORAGEは必要ありません。

+0

私のディスプレイは空白で、白いだけです。 –

関連する問題