如何在GoogleMap上将当前缩放级别作为整数获取.我需要从GMaps v1.1获取此代码:
MapView mGoogleMapView;
int zoomLevel = mGoogleMapView.getZoomLevel();
Run Code Online (Sandbox Code Playgroud)
我知道方法getMinZoomLevel()和getMaxZoomLevel()但是我在Android GMap V2文档中找不到任何可以提供当前缩放级别的内容.有没有人有关于如何做到这一点的任何指示?
任何帮助,将不胜感激.
我试图获得一个列表标记(使用GMaps V2 for Android),类似于我在GMaps V1.1 for Android中使用的getOverlays()方法:
private MapView mapView;
mapView.getOverlays().add(overlay);
Run Code Online (Sandbox Code Playgroud)
我怎么能做一些类似于我上面做的事情,但有标记?
任何帮助,将不胜感激.
android google-maps google-maps-markers google-maps-android-api-2
如何使用GMaps v2将地图中心设置为特定位置?这就是我使用GMaps v1的方式:
public void setCenter( LatLng point )
{
if( point.latitude*1000000 != 0 && point.longitude*1000000 != 0 )
{
if( mMapController != null )
{
mMapController.setCenter( point );
}
/*else if( mOpenStreetMapViewControllerSource != null )
{
mOpenStreetMapViewControllerSource.getController().setCenter( new org.osmdroid.util.GeoPoint( point.getLatitudeE6(), point.getLongitudeE6() ) );
mPostponedSetCenterPoint = point;
}*/
}
}
Run Code Online (Sandbox Code Playgroud)
我查看了GMaps v2的API,找不到和类似的功能.我该怎么做呢?
当我尝试将我的Android项目导出到APK时出现以下错误:不可翻译的资源只应在基本值/文件夹中定义.这是它遇到问题的代码:
<string-array name="about_translators" translatable="false">
Run Code Online (Sandbox Code Playgroud)
这发生在res目录的values文件夹中的array.xml文件中.它遇到问题的代码是:
translatable="false"
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?任何帮助,将不胜感激.
我看到在 Android 5.1.1 中不推荐使用 stopLeScan() 和 startLeScan()。我在替换 stopLeScan() 和 startLeScan() 方法时遇到问题。这是我的以下代码:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
final BluetoothDevice device = mLeDeviceListAdapter.getDevice(position);
if (device == null) return;
final Intent intent = new Intent(this, MainActivity.class);
//intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_NAME, device.getName());
intent.putExtra(MainActivity.EXTRAS_DEVICE_ADDRESS, device.getAddress());
if (mScanning) {
mBluetoothAdapter.stopScan(mLeScanCallback);
mBluetoothAdapter.getBluetoothLeScanner();
mScanning = false;
}
startActivity(intent);
}
private void scanLeDevice(final boolean enable) {
if (enable) {
// Stops scanning after a pre-defined scan period.
mHandler.postDelayed(new Runnable() {
@Override
public void run() { …
Run Code Online (Sandbox Code Playgroud) android bluetooth bluetooth-lowenergy android-bluetooth android-ble
我正试图拔出字符串:
[{"name":"John Doe Jr."},{"name2":"John Doe"}] & {"name":"John Doe"}
Run Code Online (Sandbox Code Playgroud)
从下面的JSON字符串中的有效负载:
{"to":"broadcast", "type":"50", "payload":[{"name":"John Doe Jr."},{"name2":"John Doe"}]}
{"to":"broadcast", "type":"50", "payload":{"name":"John Doe"}}
Run Code Online (Sandbox Code Playgroud)
使用这个正则表达式代码:
Pattern pattern = Pattern.compile("\\{(.*?)\"payload\":\"(.*?)\"\\}\\}");
Matcher matcher = pattern.matcher(jsonString);
Run Code Online (Sandbox Code Playgroud)
我收到了IllegalStateException:到目前为止没有成功匹配
我的正则表达式出了什么问题?
另外如何获得它找到的匹配数量?
任何帮助,将不胜感激.
当我调用这个createMarker()方法时,我得到一个IllegalArgumentException:
private void createMarker(GoogleMap map, MarkerOptions options, OnMarkerCreateListener listener) {
Log.e("LazyMarker", "Options var val: "+options);
Log.i("LazyMarker", "GoogleMap Value:"+map);
Log.i("LazyMarker", "OnMarkerCreateListener Value:"+listener);
marker = map.addMarker(options);
//Log.i("LazyMarker", "The value of Marker is:"+map.addMarker(options));
if (listener != null) {
listener.onMarkerCreate(this);
}
}
Run Code Online (Sandbox Code Playgroud)
这是logcat输出:
06-14 11:40:38.627: I/OGT.RideTracking(25590): Map value is: com.google.android.gms.maps.GoogleMap@4249bd30
06-14 11:40:38.627: E/LazyMarker(25590): Options var val: com.google.android.gms.maps.model.MarkerOptions@4318baf8
06-14 11:40:38.627: I/LazyMarker(25590): GoogleMap Value:com.google.android.gms.maps.GoogleMap@4249bd30
06-14 11:40:38.627: I/LazyMarker(25590): OnMarkerCreateListener Value:null
06-14 11:40:38.637: D/AndroidRuntime(25590): Shutting down VM
06-14 11:40:38.637: W/dalvikvm(25590): threadid=1: thread exiting with uncaught exception (group=0x415d7438)
06-14 …
Run Code Online (Sandbox Code Playgroud) java android google-maps-android-api-2 android-maps-v2 android-maps-extensions
我正在尝试创建一个正则表达式来检查是否输入了有效的电话号码.我的正则表达式有问题.这是我正在使用的源代码:
if (!Pattern.matches("(\\d{3}-){1,2}\\d{4}", s)) {
et.setError("Enter a valid Phone Number");
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在使用以下代码获取NullPointerException:
private ProjectionProxy proxy = new ProjectionProxy();
private GoogleMap mMap = null;
private Context context = this;
@Override
protected void onCreate(Bundle load) {
super.onCreate(load);
setContentView(R.layout.fragment_ride_tracking);
//mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap();
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.setMyLocationEnabled(true);
//SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.myMapView);
//mMap = mapFragment.getMap();
Log.e("RideTracking", "Google Map VALUE:"+mMap);
if (mMap != null) {
proxy.setProjection(mMap.getProjection());
}
Run Code Online (Sandbox Code Playgroud)
发生NullPointerException的行是这行代码:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
Run Code Online (Sandbox Code Playgroud)
我没有将我的mMap变量初始化为null.这是我的问题?
我得到并且错误表明应用程序无法破坏活动
private JMDNSService jmdnsService = null;
@Override
public void onDestroy() {
super.onDestroy();
jmdnsService = null; // destroy this object so we don't keep polling.
if (D) {Log.i(TAG, "++++ ON DESTROY +++++"); }
try {
stopJMDNS();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
stopWifi();
}
private void stopWifi() {
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);
}
private void stopJMDNS() throws IOException {
jmdnsService.shutDownJmDNS();
}
Run Code Online (Sandbox Code Playgroud)
来自JMDNSService.java的代码:
public boolean shutDownJmDNS(){
if(jmdns != null){
try {
jmdns.close();
} catch …
Run Code Online (Sandbox Code Playgroud)