Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. <uses-permission android:name="android.permission.INTERNET"/>
  2. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  3. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  4. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  5. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  6.  
  7. <uses-feature
  8. android:glEsVersion="0x00020000"
  9. android:required="true"/>
  10.  
  11. <application
  12. android:allowBackup="true"
  13. android:icon="@mipmap/ic_launcher"
  14. android:label="@string/app_name"
  15. android:supportsRtl="true"
  16. android:theme="@style/AppTheme">
  17. <activity
  18. android:name=".MainActivity"
  19. android:label="@string/app_name"
  20. android:theme="@style/AppTheme.NoActionBar">
  21. <intent-filter>
  22. <action android:name="android.intent.action.MAIN" />
  23.  
  24. <category android:name="android.intent.category.LAUNCHER" />
  25. </intent-filter>
  26. </activity>
  27.  
  28. <meta-data
  29. android:name="com.google.android.gms.version"
  30. android:value="@integer/google_play_services_version" />
  31. <meta-data
  32. android:name="com.google.android.geo.API_KEY"
  33. android:value="AIzaSyC****************************eKI"/>
  34. </application>
  35.  
  36. apply plugin: 'com.android.application'
  37.  
  38. android {
  39. compileSdkVersion 24
  40. buildToolsVersion "23.0.2"
  41.  
  42. defaultConfig {
  43. applicationId "com.hfad.mapsstudy"
  44. minSdkVersion 10
  45. targetSdkVersion 24
  46. versionCode 1
  47. versionName "1.0"
  48. }
  49. buildTypes {
  50. release {
  51. minifyEnabled false
  52. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  53. }
  54. }
  55. }
  56.  
  57. dependencies {
  58. compile fileTree(include: ['*.jar'], dir: 'libs')
  59. testCompile 'junit:junit:4.12'
  60. compile 'com.android.support:appcompat-v7:24.0.0'
  61. compile 'com.android.support:design:24.0.0'
  62. compile 'com.google.android.gms:play-services:9.0.2'
  63. }
  64.  
  65. <?xml version="1.0" encoding="utf-8"?>
  66. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  67. xmlns:app="http://schemas.android.com/apk/res-auto"
  68. xmlns:tools="http://schemas.android.com/tools"
  69. android:layout_width="match_parent"
  70. android:layout_height="match_parent"
  71. android:paddingBottom="@dimen/activity_vertical_margin"
  72. android:paddingLeft="@dimen/activity_horizontal_margin"
  73. android:paddingRight="@dimen/activity_horizontal_margin"
  74. android:paddingTop="@dimen/activity_vertical_margin"
  75. app:layout_behavior="@string/appbar_scrolling_view_behavior"
  76. tools:context="com.hfad.mapsstudy.MainActivity"
  77. tools:showIn="@layout/activity_main">
  78.  
  79. <fragment xmlns:android="http://schemas.android.com/apk/res/android"
  80. android:name="com.google.android.gms.maps.SupportMapFragment"
  81. android:id="@+id/map"
  82. android:layout_width="match_parent"
  83. android:layout_height="match_parent"/>
  84. </RelativeLayout>
  85.  
  86. package com.hfad.mapsstudy;
  87.  
  88. import android.os.Bundle;
  89. import android.support.design.widget.FloatingActionButton;
  90. import android.support.design.widget.Snackbar;
  91. import android.support.v4.app.FragmentActivity;
  92. import android.support.v7.app.AppCompatActivity;
  93. import android.support.v7.widget.Toolbar;
  94. import android.view.View;
  95. import android.view.Menu;
  96. import android.view.MenuItem;
  97.  
  98. import com.google.android.gms.maps.GoogleMap;
  99. import com.google.android.gms.maps.MapFragment;
  100. import com.google.android.gms.maps.OnMapReadyCallback;
  101. import com.google.android.gms.maps.SupportMapFragment;
  102. import com.google.android.gms.maps.model.LatLng;
  103. import com.google.android.gms.maps.model.MarkerOptions;
  104.  
  105. public class MainActivity extends FragmentActivity implements OnMapReadyCallback {
  106.  
  107. @Override
  108. protected void onCreate(Bundle savedInstanceState) {
  109. super.onCreate(savedInstanceState);
  110. setContentView(R.layout.activity_main);
  111. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  112.  
  113.  
  114. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  115. .findFragmentById(R.id.map);
  116.  
  117. mapFragment.getMapAsync(this);
  118.  
  119. FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  120. fab.setOnClickListener(new View.OnClickListener() {
  121. @Override
  122. public void onClick(View view) {
  123. Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
  124. .setAction("Action", null).show();
  125. }
  126. });
  127. }
  128.  
  129. @Override
  130. public boolean onCreateOptionsMenu(Menu menu) {
  131. // Inflate the menu; this adds items to the action bar if it is present.
  132. getMenuInflater().inflate(R.menu.menu_main, menu);
  133. return true;
  134. }
  135.  
  136. @Override
  137. public boolean onOptionsItemSelected(MenuItem item) {
  138. // Handle action bar item clicks here. The action bar will
  139. // automatically handle clicks on the Home/Up button, so long
  140. // as you specify a parent activity in AndroidManifest.xml.
  141. int id = item.getItemId();
  142.  
  143. //noinspection SimplifiableIfStatement
  144. if (id == R.id.action_settings) {
  145. return true;
  146. }
  147.  
  148. return super.onOptionsItemSelected(item);
  149. }
  150.  
  151. @Override
  152. public void onMapReady(GoogleMap googleMap)
  153. {
  154. googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
  155.  
  156. googleMap.addMarker(new MarkerOptions()
  157. .position(new LatLng(0, 0))
  158. .title("Marker"));
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement