Update project SDK and API key
Этот коммит содержится в:
@@ -1,13 +1,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion "23.0.1"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.traccar.manager"
|
applicationId "org.traccar.manager"
|
||||||
minSdkVersion 10
|
minSdkVersion 10
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:appcompat-v7:22.2.1'
|
compile 'com.android.support:appcompat-v7:23.1.0'
|
||||||
compile 'com.google.android.gms:play-services:7.5.0'
|
compile 'com.google.android.gms:play-services:8.4.0'
|
||||||
|
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,9 @@
|
|||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme" >
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.version"
|
android:name="com.google.android.geo.API_KEY"
|
||||||
android:value="@integer/google_play_services_version" />
|
|
||||||
<meta-data
|
|
||||||
android:name="com.google.android.maps.v2.API_KEY"
|
|
||||||
android:value="@string/google_maps_key" />
|
android:value="@string/google_maps_key" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
|||||||
@@ -1,65 +1,36 @@
|
|||||||
package org.traccar.manager;
|
package org.traccar.manager;
|
||||||
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
|
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||||
import com.google.android.gms.maps.SupportMapFragment;
|
import com.google.android.gms.maps.SupportMapFragment;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
|
|
||||||
public class MainActivity extends FragmentActivity {
|
public class MainActivity extends FragmentActivity implements OnMapReadyCallback {
|
||||||
|
|
||||||
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
|
private GoogleMap map;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
setUpMapIfNeeded();
|
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
||||||
|
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentById(R.id.map);
|
||||||
|
mapFragment.getMapAsync(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onMapReady(GoogleMap googleMap) {
|
||||||
super.onResume();
|
map = googleMap;
|
||||||
setUpMapIfNeeded();
|
|
||||||
|
LatLng sydney = new LatLng(-34, 151);
|
||||||
|
map.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
||||||
|
map.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
|
|
||||||
* installed) and the map has not already been instantiated.. This will ensure that we only ever
|
|
||||||
* call {@link #setUpMap()} once when {@link #mMap} is not null.
|
|
||||||
* <p/>
|
|
||||||
* If it isn't installed {@link SupportMapFragment} (and
|
|
||||||
* {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
|
|
||||||
* install/update the Google Play services APK on their device.
|
|
||||||
* <p/>
|
|
||||||
* A user can return to this FragmentActivity after following the prompt and correctly
|
|
||||||
* installing/updating/enabling the Google Play services. Since the FragmentActivity may not
|
|
||||||
* have been completely destroyed during this process (it is likely that it would only be
|
|
||||||
* stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this
|
|
||||||
* method in {@link #onResume()} to guarantee that it will be called.
|
|
||||||
*/
|
|
||||||
private void setUpMapIfNeeded() {
|
|
||||||
// Do a null check to confirm that we have not already instantiated the map.
|
|
||||||
if (mMap == null) {
|
|
||||||
// Try to obtain the map from the SupportMapFragment.
|
|
||||||
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
|
|
||||||
.getMap();
|
|
||||||
// Check if we were successful in obtaining the map.
|
|
||||||
if (mMap != null) {
|
|
||||||
setUpMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is where we can add markers or lines, add listeners or move the camera. In this case, we
|
|
||||||
* just add a marker near Africa.
|
|
||||||
* <p/>
|
|
||||||
* This should only be called once and when we are sure that {@link #mMap} is not null.
|
|
||||||
*/
|
|
||||||
private void setUpMap() {
|
|
||||||
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
<fragment
|
||||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent" android:id="@+id/map" tools:context=".MainActivity"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:name="com.google.android.gms.maps.SupportMapFragment" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/map"
|
||||||
|
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||||
|
tools:context=".MainActivity" />
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">AIzaSyB2sTYAPuWFpWHCP-cbGBYL2qJVmsMnfrQ</string>
|
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">AIzaSyAMQYClXhA2tZdfCzu9EK9wUDWtCRQ6Bj0</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<!--
|
|
||||||
TODO: Before you run your application, you need a Google Maps API key.
|
|
||||||
|
|
||||||
To get one, follow this link, follow the directions and press "Create" at the end:
|
|
||||||
|
|
||||||
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=CC:52:01:6E:7D:18:68:C6:89:42:DE:13:CB:F5:83:FC:C6:E3:81:64%3Borg.traccar.manager
|
|
||||||
|
|
||||||
You can also add your credentials to an existing key, using this line:
|
|
||||||
CC:52:01:6E:7D:18:68:C6:89:42:DE:13:CB:F5:83:FC:C6:E3:81:64;org.traccar.manager
|
|
||||||
|
|
||||||
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
|
|
||||||
string in this file.
|
|
||||||
-->
|
|
||||||
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
|
|
||||||
YOUR_KEY_HERE
|
|
||||||
</string>
|
|
||||||
</resources>
|
|
||||||
Ссылка в новой задаче
Block a user