Android use Baidu lbs SDK (vi) intercept trajectory map and share

Source: Internet
Author: User


@@ -1, -+1, -@ @packagecom. Zms. baidulbs;+import Java. IO. File;Import Java. IO. FileInputStream;+import Java. IO. FileNotFoundException;+import Java. IO. FileOutputStream;+import Java. IO. IOException;Import Java. Util. ArrayList;Import Java. Util. List;import org. Apache. HTTP. Util. Encodingutils;Import Android. App. Activity;+import Android. Content. Intent;Import Android. Content. Sharedpreferences;+import Android. Graphics. Bitmap;+import Android. Graphics. Color;+import Android. NET. Uri;Import Android. OS. Bundle;+import Android. View. View;+import Android. View. Window;Import Android. Widgets. Button;Import Android. Widgets. Toast;@@ - -,6+ the,7@ @importcom. Baidu. Mapapi. Map. Overlayoptions;Importcom. Baidu. Mapapi. Map. Polylineoptions;Importcom. Baidu. Mapapi. Map. Baidumap. Onmarkerclicklistener;+importcom. Baidu. Mapapi. Map. Baidumap. Snapshotreadycallback;Importcom. Baidu. Mapapi. Map. Infowindow. Oninfowindowclicklistener;Importcom. Baidu. Mapapi. Model. LATLNG;Importcom. Zms. baidulbs. R;@@ - the, One+ $, -@ @private Infowindow Minfowindow;Private Marker Mmarkerstart;Private Marker Mmarkerend;+ Private Button Btnshare, Btnback;public double mroutelatitude =0.0;public double mroutelongitude =0.0;Private final String Route_path ="/sdcard/route/";+ Private String FilePath ="";Private Routeadapter Routeadapter = new Routeadapter ();Initialize the global bitmap information, when not in time recycle@@-Wuyi, -+ -, A@ @protected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method Stubsuper. OnCreate(savedinstancestate);+ Requestwindowfeature (Window. FEATURE_no_title);Setcontentview (R. Layout. Route_show);-String FilePath ="";+//Hide Status bar+ View decorview = GetWindow (). Getdecorview();+ Decorview. Setsystemuivisibility(View. SYSTEM_ui_flag_fullscreen);+ + Btnshare = (Button) Findviewbyid (R. ID. Btnshare);+ Btnback = (Button) Findviewbyid (R. ID. Btnback);+ Btnshare. Setonclicklistener(New Myonclicklistener ());+ Btnback. Setonclicklistener(New Myonclicklistener ());+bundle extras = getintent (). Getextras();if (extras! = null) {FilePath = Extras. getString("FilePath");-Settitle (FilePath. Substring(0, FilePath. Length() -4));+//Settitle (FilePath. Substring(0, FilePath. Length() -4));} else {Toast. Maketext(Getapplicationcontext (),"Trace file does not exist", Toast. LENGTH_short). Show();@@ - in,6+ the,Wuyi@@ protected void OnCreate (Bundle savedinstancestate) {}+ class Myonclicklistener implements View. Onclicklistener{+ @Override + public void OnClick (View v) {+ switch (V. GetId()) {+ Case R. ID. Btnshare: + Mbaidumap. Snapshot(New Snapshotreadycallback () {+ public void Onsnapshotready (Bitmap snapshot) {+ File File = new file (Route_path + file Path +". png");+ FileOutputStream out;+ try {+ out= new FileOutputStream (file);+ if (snapshot. Compress(Bitmap. Compressformat. PNG,+ -, out)) {+ out. Flush();+ out. Close();+}+ Intent Intent = new Intent (Intent. ACTION_send);+ URI uri = Uri. FromFile(file);+ Intent. SetType("Image/png");+ Intent. PutExtra(Intent. EXTRA_stream, URI);+ Intent. PutExtra(Intent. EXTRA_title,"Share track map to");+ Intent chooserintent = Intent. Createchooser(intent,+"Share track");+ if (chooserintent = = null) {+ return;+}+ try {+ startactivity (chooserintent);+} catch (Android. Content. ActivitynotfoundexceptionEx) {+}+} catch (FileNotFoundException e) {+ E. Printstacktrace();+} catch (IOException e) {+ E. Printstacktrace();+   }+   }+   });+ Break;+ Case R. ID. Btnback: + Finish ();+ Break;+   }+   }+   }+/*** reading the latitude and longitude form from a file *

Android use Baidu lbs SDK (vi) intercept trajectory map and share

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.