public class MainActivity extends Activity {
private static final String MAPFILE = "philippines.map";
private MapView mapView;
private TileCache tileCache;
private TileRendererLayer tileRendererLayer;
private MyLocationOverlay myLocationOverlay;
private MapViewPosition mapViewPosition;
private LocationManager locationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout mylayout=(RelativeLayout)findViewById(R.id.mainView);
AndroidGraphicFactory.createInstance(this.getApplication());
this.mapView = new MapView(this);
mylayout.addView(mapView);
this.mapView.setClickable(true);
this.mapView.getMapScaleBar().setVisible(true);
this.mapView.setBuiltInZoomControls(true);
this.mapView.getMapZoomControls().setZoomLevelMin((byte) 10);
this.mapView.getMapZoomControls().setZoomLevelMax((byte) 20);
// create a tile cache of suitable size
this.tileCache = AndroidUtil.createTileCache(this, "mapcache",
mapView.getModel().displayModel.getTileSize(), 1f,
this.mapView.getModel().frameBufferModel.getOverdrawFactor());
}
@Override
protected void onStart() {
super.onStart();
this.mapView.getModel().mapViewPosition.setCenter(new LatLong(13.000,122.000));
this.mapView.getModel().mapViewPosition.setZoomLevel((byte) 12);
// tile renderer layer using internal render theme
MapDataStore mapDataStore = new MapFile(getMapFile());
this.tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
this.mapView.getModel().mapViewPosition, false, true, AndroidGraphicFactory.INSTANCE);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
// only once a layer is associated with a mapView the rendering starts
this.mapView.getLayerManager().getLayers().add(tileRendererLayer);
}
@Override
protected void onDestroy() {
super.onDestroy();
this.mapView.destroy();
}
private File getMapFile() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
File file = new File("/mnt/sdcard/"+MAPFILE);
return file;
}
10-03 00:07:01.680 30050-30050/com.example.galvez.mapsforge E/Zygote﹕ MountEmulatedStorage()
10-03 00:07:01.680 30050-30050/com.example.galvez.mapsforge E/Zygote﹕ v2
10-03 00:07:01.680 30050-30050/com.example.galvez.mapsforge I/libpersona﹕ KNOX_SDCARD checking this for 10268
10-03 00:07:01.680 30050-30050/com.example.galvez.mapsforge I/libpersona﹕ KNOX_SDCARD not a persona
10-03 00:07:01.710 30050-30050/com.example.galvez.mapsforge I/SELinux﹕ Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_SM-G900F_5.0 ver=27
10-03 00:07:01.710 30050-30050/com.example.galvez.mapsforge I/SELinux﹕ Function: selinux_compare_spd_ram , priority [1] , priority version is VE=SEPF_SM-G900F_5.0_0027
10-03 00:07:01.720 30050-30050/com.example.galvez.mapsforge E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
10-03 00:07:01.720 30050-30050/com.example.galvez.mapsforge I/art﹕ Late-enabling -Xcheck:jni
10-03 00:07:01.770 30050-30050/com.example.galvez.mapsforge D/TimaKeyStoreProvider﹕ TimaSignature is unavailable
10-03 00:07:01.770 30050-30050/com.example.galvez.mapsforge D/ActivityThread﹕ Added TimaKeyStore provider
10-03 00:07:02.060 30050-30050/com.example.galvez.mapsforge D/ResourcesManager﹕ creating new AssetManager and set to /data/app/com.example.galvez.mapsforge-1/base.apk
10-03 00:07:02.110 30050-30050/com.example.galvez.mapsforge V/BitmapFactory﹕ DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/sym_def_app_icon.png
10-03 00:07:02.130 30050-30050/com.example.galvez.mapsforge D/AndroidRuntime﹕ Shutting down VM
10-03 00:07:02.130 30050-30050/com.example.galvez.mapsforge E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.galvez.mapsforge, PID: 30050
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.galvez.mapsforge/com.example.galvez.mapsforge.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class org.mapsforge.map.android.view.MapView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class org.mapsforge.map.android.view.MapView
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:428)
at android.app.Activity.setContentView(Activity.java:2241)
at com.example.galvez.mapsforge.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:428)
at android.app.Activity.setContentView(Activity.java:2241)
at com.example.galvez.mapsforge.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'org.mapsforge.core.graphics.Paint org.mapsforge.core.graphics.GraphicFactory.createPaint()' on a null object reference
at org.mapsforge.map.view.FpsCounter.createPaintFront(FpsCounter.java:36)
at org.mapsforge.map.view.FpsCounter.<init>(FpsCounter.java:62)
at org.mapsforge.map.android.view.MapView.<init>(MapView.java:73)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:428)
at android.app.Activity.setContentView(Activity.java:2241)
at com.example.galvez.mapsforge.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/mainView"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<org.mapsforge.map.android.view.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
mapsforge-core-0.5.1.jar
mapsforge-map-0.5.1.jar
mapsforge-map-android-0.5.1.jar
mapsforge-map-reader-0.5.1.jar
我发现您的代码有两个问题:
AndroidGraphicFactory.CreateInstance(This.GetApplication())
语句应在设置由@Nikolai Doronin注释的内容视图之前调用.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidGraphicFactory.createInstance(this.getApplication());
setContentView(R.layout.activity_main);
this.mapView = (MapView) findViewById(R.id.mapView);
this.mapView.setClickable(true);
...
在此处输入图像描述 我想安装Android Studio,但在图片中显示的状态下,它无法再安装并且已停止。
本文向大家介绍AndroidStudio:手势识别,包括了AndroidStudio:手势识别的使用技巧和注意事项,需要的朋友参考一下 一内容:设计一个手写字体识别程序。 二实现 ①建立一个存放手写字体的数据库 ②activity_main.xml 3.MainActivity.java 三效果 以上所述是小编给大家介绍的AndroidStudio手势识别详解整合,希望对大家有所帮助,如果大家有任
我试图在android studio上使用java 1.7版,但不幸的是,它不能正常工作。。。如果在
1. 建立广告位,获取广告位ID 登录系统后台创建APP和广告位,获取AppID 以及 广告位ID 根据需求配置广告位 2. 工程中添加SDK代码 初始化SDK (详细说明) 配置AndroidManifest,声明权限和组件 初始化全局SDK代码 根据创建的广告位样式,添加相应的广告样式的代码 横幅(Banner)广告样式 插屏(Interstitial)广告样式 开屏(Splash)广告样式
问题内容: 我的日历有问题。这是代码: 不能运行我的项目,因为在AndroidStudio显示错误,等…我得到nullPointException在模拟器运行时 它说 必须是以下之一:java.util.Calendar.DAY_OF_MONTHjava.util.Calendar.MONTH等… 我不明白此错误,因为它是其中之一 我有进口 对不起,我错过了它的初始化,但是还有另一个我想使用Cal
我想做一个应用程序,使用谷歌翻译API。自从我添加了 我的构建中的依赖项。gradle我有个错误: 现在必须显式声明注释处理器。发现编译类路径上的以下依赖项包含注释处理器。请将它们添加到annotationProcessor配置中。-自动值-1.2。jar(com.google.auto.value:auto-value:1.2)或者,设置android。defaultConfig。javaCom
前面我们讲了 Gradle 在 Android 项目中的配置,我们提到有一个闭包 signingConfigs 是配置 Android 应用签名信息的。那么今天我们就来讲讲如何通过 AndroidStudio 对 APK 进行签名。 1. 新建 keyStore 文件 我们下面一步步带大家,用 AndroidStudio 来配置签名。 首先顶部菜单栏找到 Build 点击他我们会看到 Genera
问题内容: 我正在尝试在Android Studio中使用Java版本1.7,但是很遗憾,它无法正常工作…如果将版本设置为 但是,当我使用带有字符串的声明语句时,出现了在Java 1.7中应该发生的错误,因此我是否需要设置其他设置? 问题答案: 不,没有设置可更改。Android SDK不支持完整的Java 7语法,因此您不能使用它。 请注意,最新的android版本支持java.nio。*(ja