Commit template Android project
Этот коммит содержится в:
@@ -0,0 +1,13 @@
|
||||
package org.traccar.manager;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">AIzaSyB2sTYAPuWFpWHCP-cbGBYL2qJVmsMnfrQ</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.traccar.manager" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
|
||||
<!--
|
||||
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
|
||||
Google Maps Android API v2, but are recommended.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
<meta-data
|
||||
android:name="com.google.android.maps.v2.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.traccar.manager;
|
||||
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
public class MainActivity extends FragmentActivity {
|
||||
|
||||
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
setUpMapIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setUpMapIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<fragment 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:id="@+id/map" tools:context=".MainActivity"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment" />
|
||||
Двоичные данные
Двоичный файл не отображается.
|
После Ширина: | Высота: | Размер: 3.3 KiB |
Двоичные данные
Двоичный файл не отображается.
|
После Ширина: | Высота: | Размер: 2.2 KiB |
Двоичные данные
Двоичный файл не отображается.
|
После Ширина: | Высота: | Размер: 4.7 KiB |
Двоичные данные
Двоичный файл не отображается.
|
После Ширина: | Высота: | Размер: 7.5 KiB |
@@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">TraccarManager</string>
|
||||
<string name="title_activity_main">Main</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,18 @@
|
||||
<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