一个最简单的基站定位定出自己位置的小程序

一个最简单的基站定位定出自己位置的小程序

2023年7月4日发(作者:)

⼀个最简单的基站定位定出⾃⼰位置的⼩程序主程序:jzdw包: 1 package ; 2

3 import rmat; 4 import DateFormat; 5 import ; 6

7 import ty; 8 import on; 9 import ; 10 import r; 11 import e; 12 import ; 13 import ssBar; 14 import ew; 15

16 import nager; 17 import nt; 18 import onListener; 19 import Info; 20 import ineResult; 21 import ingRouteResult; 22 import ralListener; 23 import esult; 24 import ch; 25 import chListener; 26 import estionResult; 27 import sitRouteResult; 28 import ingRouteResult; 29

30

31

32 public class Jzdw extends Activity {

33 public TextView myDate, jingdu,mylocation; 34 public BMapManager mapManager; 35 private String lng1; 36 private String lat1; 37 private String date; 38 private String Precision; 39 private Handler handler = new Handler() { 40 @Override 41 public void handleMessage(Message msg) { 42 if ( == 1) { 43 Log.i("out","handlemessenge"); 44 DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 45 date = (new Date()); 46 t(date); 47 Bundle data = a(); 48 // lng1 = ing("Longltude"); 49 lng1 = ing("Longltude"); 50 lat1 = ing("Latitude"); 51 //jzdwaddress = ing("jzdwaddress"); 52 Precision = ing("accuracy"); 53 t(Precision); 54 t("经度为:" + lng1 + "n维度为:" + lat1); 55

56 }} 57 }; 58

59 @Override

60 public void onCreate(Bundle savedInstanceState) {

61 te(savedInstanceState);

62 setContentView(); 63 myDate=(TextView)findViewById(.t1); 64 jingdu=(TextView)findViewById(.t3); 65 mylocation = (TextView) ewById(.t2); 66 new Thread(new Jzdw1(handler, this)).start(); 67

68 /*

69 mapManager=new BMapManager(this); 70

71 ("471066e711cc4128a04b3e3b1930a422", new MyMKGeneralListener()); 72

73

74 ationManager().setNotifyInternal(20, 5); 75

76 77 ationManager().requestLocationUpdates(new MyLocationListener()); 78

79 (); 80 */

81

82 // mapManager = new BMapManager(this); 83 // ("EDB67AD764D300895C95ABA02A4DDC58D5485CCD", 84 // new MyMKGeneralListener()); 85 // // 设置通知间隔:iMaxSecond - 最⼤通知间隔,单位:秒;iMinSecond - 最⼩通知间隔,单位:秒 86 // ationManager().setNotifyInternal(20, 5); 87 // 88 // ationManager().requestLocationUpdates( 89 // new MyLocationListener()); 90 // (); 91

92 }

93 /*

94 // 定位⾃⼰的位置,只定位⼀次

95 class MyLocationListener implements LocationListener { 96

97 @Override 98 public void onLocationChanged(Location arg0) { 99

100 double jindu1 = itude();101 double weidu1 = gitude();102

103 int jindu = (int) (itude()*1000000);104 int weidu = (int) (gitude()*1000000);105 t("经度:" + jindu1 + ",纬度:" + weidu1);106 n("1111经度:" + jindu1 + ",111纬度:" + weidu1);107 MKSearch search = new MKSearch();108 (mapManager, new MyMKSearchListener());109 eGeocode(new GeoPoint(jindu, weidu));110 }111

112 }113

114 class MyMKSearchListener implements MKSearchListener {115

116 @Override117 public void onGetAddrResult(MKAddrInfo arg0, int arg1) {118 if (arg0 == null) {119 t("没有获取想要的位置");120 } else {121 GeoPoint point = ;122 t("地址:" + r + ",坐标:"123 + itudeE6() + "," + gitudeE6());124 }125 }126

127 @Override128 public void onGetDrivingRouteResult(MKDrivingRouteResult arg0, int arg1) {129 // TODO Auto-generated method stub130

131 }132

133 @Override134 public void onGetPoiResult(MKPoiResult arg0, int arg1, int arg2) {135 // TODO Auto-generated method stub136

137 }138

139 @Override140 public void onGetTransitRouteResult(MKTransitRouteResult arg0, int arg1) {141 // TODO Auto-generated method stub142

143 }144

145 @Override146 public void onGetWalkingRouteResult(MKWalkingRouteResult arg0, int arg1) {147 // TODO Auto-generated method stub148

149 }150

151 @Override152 public void onGetBusDetailResult(MKBusLineResult arg0, int arg1) {153 // TODO Auto-generated method stub154

155 }156

157 @Override158 public void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) {159 // TODO Auto-generated method stub160 161 }162

163

164

165 }166

167 // 常⽤事件监听,⽤来处理通常的⽹络错误,授权验证错误等168 class MyMKGeneralListener implements MKGeneralListener {169

170 @Override171 public void onGetNetworkState(int arg0) {172

173 }174

175 @Override176 public void onGetPermissionState(int arg0) {177

178 }179

180 }*/181 }jzdw1包: 1 package ; 2

3

4

5 import nager; 6 import nt; 7 import onListener; 8 import Info; 9 import ineResult; 10 import ingRouteResult; 11 import ralListener; 12 import esult; 13 import chListener; 14 import estionResult; 15 import sitRouteResult; 16 import ingRouteResult; 17

18 import t; 19 import on; 20 import ; 21 import r; 22 import e; 23 import onyManager; 24 import ; 25

26

27 public class Jzdw1 extends Thread{ 28 private TelephonyManager tm; 29 private Handler handler; 30 private Context context; 31 Double lat; 32 Double lng; 33 public BMapManager mapManager; 34

35 public Jzdw1(Handler handler, Context context) { 36

37 r = handler; 38 t = context; 39

40 mapManager=new BMapManager(context);

41 Log.i("out","gouzao"); 42 ("471066e711cc4128a04b3e3b1930a422", new MyMKGeneralListener());

43 ationManager().setNotifyInternal(20, 5); 44 } 45

46 @Override 47 public void run() { 48 Log.i("out","run");

49 ationManager().requestLocationUpdates(new MyLocationListener()); 50 (); 51 } 52

53 class MyLocationListener implements LocationListener { 54

55 @Override 56 public void onLocationChanged(Location arg0) { 57 Integer jingdu = (int) (itude()*1000000); 58 Integer weidu = (int) (gitude()*1000000); 59 Log.i("out","listener"); 60 // Integer jingdu = (int) (itude()*1440000); 61 // Integer weidu = (int) (gitude()*1440000); 62

63

64 String Accuray=f(uracy()); 65 Bundle mydata=new Bundle(); 66 Message msg=new Message(); 67 ing("Longltude",f(jingdu)); 68 ing("Latitude",f(weidu)); 69 ing("accuracy",Accuray);

70

71 a(mydata); 72 =1; 73 ssage(msg);

74 } 75

76 } 77

78 class MyMKSearchListener implements MKSearchListener { 79

80 @Override 81 public void onGetAddrResult(MKAddrInfo arg0, int arg1) { 82 if (arg0 == null) { 83 //t("没有获取想要的位置"); 84 } else { 85 GeoPoint point = ; 86 // ("n" + r); 87 } 88 } 89

90 @Override 91 public void onGetBusDetailResult(MKBusLineResult arg0, int arg1) { 92

93 } 94

95 @Override 96 public void onGetDrivingRouteResult(MKDrivingRouteResult arg0, int arg1) { 97

98 } 99

100 @Override101 public void onGetPoiResult(MKPoiResult arg0, int arg1, int arg2) {102

103 }104

105 @Override106 public void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) {107

108 }109

110 @Override111 public void onGetTransitRouteResult(MKTransitRouteResult arg0, int arg1) {112

113 }114

115 @Override116 public void onGetWalkingRouteResult(MKWalkingRouteResult arg0, int arg1) {117

118 }119

120 // @Override121 // public void onGetRGCShareUrlResult(String arg0, int arg1) {122 // // TODO Auto-generated method stub123 //

124 // }125

126 }127

128

129 // 常⽤事件监听,⽤来处理通常的⽹络错误,授权验证错误等130 class MyMKGeneralListener implements MKGeneralListener {131

132 @Override133 public void onGetNetworkState(int arg0) {134

135 }136

137 @Override138 public void onGetPermissionState(int arg0) {139

140 }141

142 }143 }xml⽂件: 1 2 7

8 android:id="@+id/t1"

9 android:layout_width="fill_parent"

10 android:layout_height="wrap_content"

11 android:text="@string/hello"12 />13

14 android:id="@+id/t2"

15 android:layout_width="fill_parent"

16 android:layout_height="wrap_content"

17 android:text="@string/hello"18 />19

21 android:layout_width="fill_parent"

22 android:layout_height="wrap_content"

23 android:text="@string/hello"24 />25 记得在清单⽂件中添加权限哦(万能版): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

20 21

22

23

24

25 26

27

28

29

30

31 32 33 34

35 36 37 38 39

40

41

发布者:admin,转转请注明出处:http://www.yc00.com/web/1688420319a135720.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信